I am creating a connection with SQL SERVER and AVRO format but when I go to KsqlDB and create my table, the records are being multiplied :C please help me! :c
How do you query the table? The two statement you show create the table only.
If you query
EMIT CHANGES clause, you get the changelog of the table, not a “result snapshot”. Note that
CREATE TABLE ... AS SELECT... effectively creates an ever changing materialized view, ie, the table is updated for each input record to
EMIT CHANGES (with `auto.offset.reset=“earliest”) return the changelog of the result table / MV.
SELECT * FROM table_orders and
SELECT * FROM table_orders EMIT CHANGES are two quite different queries.
Sure, I’m using SELECT * FROM TABLE_ORDERS EMIT CHANGES;
and I see that my rows are multiplying and not updating.
I don’t understand why this happens :C
Try to omit
EMIT CHANGES and just do
SELECT * FROM table_orders.
Your result table starts as an empty table, and for each update to the table, an update record is written into the topic that is backing the table. When you add
EMIT CHANGES you basically don’t query RocksDB state store, but you query the topic and thus you don’t get the current content of the table but the full change history of the table.
Yes thanks! effectively if I omit EMIT CHANGES now I can see the table without the duplicates,
How can I solve it so that it does not bring me the history?
Not sure what you try to do? My understanding was that
SELECT * FROM table_orders is the solution?
ok but I need that table with unique values to join them to other streams.
Why are the values replicated when I use emit change, did I configure it wrong?
When you issue a persistent query
CREATE STREAM AS... and you do a STREAM-TABLE join, the stream will do a lookup into RocksDB and there will be only one row for the ID. Note that the table is not “static” for this case, but it will be updated is new table-input data arrives.
So you don’t need to worry about anything. If you do
SELECT * FROM table_orders EMIT CHANGES you issue a totally different query that does not use RocksDB but read the topic. But when you do a stream-table join, RocksDB will be used.
thanks for your answer, i will try it
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.