I’m making some test with Kafka and KSQL and I want to know how to deal with duplicate keys. Let me show you my test case:
Firstly, I created a topic named as ACCOUNT with a key “id” and some test data with the same key was pushed to the topic.
And after this I created a Table with this command:
CREATE TABLE accounts (ID VARCHAR PRIMARY KEY, number VARCHAR, BRANCH VARCHAR, bank VARCHAR, balance double, owner VARCHAR) WITH (KAFKA_TOPIC='account', VALUE_FORMAT='JSON');
The problem is: a select with “select * from accounts where id = ‘7’ EMIT CHANGES;” shows repeated rows.
What I need to do to keep only the last row based on the primary key?