Search code examples
ksqldb

How can I replace a ksqlDB table while keeping the same state store?


Using Confluent's ksqlDB 5.5.1 (which relates to ksqlDB 0.7.1 I think), I created an aggregated table:

CREATE TABLE xxx WITH (KAFKA_TOPIC = 'xxx') AS
SELECT xxx
FROM xxx
GROUP BY xxx
EMIT CHANGES;

Let's say I have to add attribute yyy to query. I have to DROP the table and re-create it. But in doing so, a new state is created and I lose all the old aggregated value.

One workaround would be to have infinite retention and re-create the table with 'auto.offset.reset'='earliest' but I'm looking for a better solution that doesn't involve infinite retention.

Any idea? It would be great to be able to do REPLACE TABLE xxx AS ....


Solution

  • This is not currently possible, but is being worked on: https://github.com/confluentinc/ksql/blob/master/design-proposals/klip-28-create-or-replace.md