2

I would like to ask can i set the key field when creating table?

I have created a table by aggregation as below:

CREATE TABLE withdrawal_less_than_5min AS 
SELECT executedate, status, count(*) as count 
FROM TB3_WITHDRAW_RECORD_EXCLUDE_INTERNAL_USERS 
GROUP BY executedate,status;

And when I DESCRIBE EXTENDED withdrawal_less_than_5min the key field of the table is set as below, which i believe should be the executedate and status.

Key field : KSQL_INTERNAL_COL_0|+|KSQL_INTERNAL_COL_1

However when I try to join it with another table with the same aggregation it return this error.

Source table (A) key column (KSQL_INTERNAL_COL_0|+|KSQL_INTERNAL_COL_1) 
is not the column used in the join criteria (EXECUTEDATE).

How do I set the key field? Thank you.

Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137
kurapika
  • 166
  • 1
  • 12

1 Answers1

-1

You can create key through following way -

CREATE TABLE withdrawal_less_than_5min with (key='EXECUTEDATE') AS 
SELECT executedate, status, count(*) as count 
FROM TB3_WITHDRAW_RECORD_EXCLUDE_INTERNAL_USERS 
GROUP BY executedate,status partition by 'EXECUTEDATE';

You can follow Robin's blog also - https://www.confluent.io/stream-processing-cookbook/ksql-recipes/inspecting-changing-topic-keys.

For any errors or question with Ksql, Search Robin Moffet, he has already answered our queries to help :)

Varun Bajaj
  • 1,033
  • 8
  • 16