Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSQL multi-table join by 2 different keys which are not the partition key #7269

Closed
Psykepro opened this issue Mar 22, 2021 · 1 comment
Closed

Comments

@Psykepro
Copy link

Psykepro commented Mar 22, 2021

Is it possible to join 3 tables by using 2 different keys from the first table to join the other 2 tables? Because from what I see it is not possible as the joins are only supported by partition key and I can't partition the table by 2 keys.

kdqlDB Server version: v6.0.2

I tried like that:

CREATE TABLE TABLE_TRANSACTIONS_ENRICHED AS
    SELECT
        a.AGR_SERIAL, a.AGR_START_DATE, a.AGR_END_DATE,
        t.TRN_SERIAL, t.TRN_DEBIT_VALUE, t.TRN_CREDIT_VALUE, t.TRN_TRANSACTION_COMMENT, t.TRN_PAYING_IN_REFERENCE, t.TRN_DATE_TIME, t.TRN_EFFECTIVE_DATE, t.__OP,
        tt.TRT_DESCRIPTION
  FROM TABLE_TRANSACTIONS as t
    LEFT JOIN TABLE_TRANSACTION_TYPES as tt ON t.TRN_TYPE = tt.TRT_SERIAL
    LEFT JOIN TABLE_AGREEMENTS as a ON t.TRN_AGREEMENT = a.AGR_SERIAL

Where:
TABLE_TRANSACTIONS - Partitioned by TRN_SERIAL
TABLE_TRANSACTION_TYPES - Partitioned by TRT_SERIAL
TABLE_AGREEMENTS - Partitioned by AGR_SERIAL

But got the following error because TABLE_TRANSACTIONS isn't partitioned by TRN_TYPE:
Cannot repartition a TABLE source. If this is a join, make sure that the criteria uses the TABLE's key column TRN_SERIAL instead of TRN_TYPE

Please help this is the last thing I need to finish everything

@agavra
Copy link
Contributor

agavra commented Mar 22, 2021

Hello @Psykepro - this is currently not possible. I'll close this as a duplicate of #4424 - you can try this suggestion #4424 (comment) in the meantime.

@agavra agavra closed this as completed Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants