简体   繁体   中英

How do i set a key field when creating table in KSQL?

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.

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM