I have defined a stream
CREATE STREAM QUOTE (quoteId VARCHAR,
counterPartyId VARCHAR)
WITH (KAFKA_TOPIC='quotes',
VALUE_FORMAT='JSON',
KEY='quoteId');
I want to aggregate how many quotes I got so far , and the last quoteId on that event
CREATE TABLE KQUOTE AS
SELECT Max(CAST(quoteId as INT)) as quoteId,COUNT(*) AS COUNT
FROM QUOTE
GROUP BY 1;
Turn this Table to Stream cause I want to know the aggregation result history. (Seem like I have to use underlying topic to create stream. Can't directly create stream from table 'KQUOTE').
CREATE stream KQuoteStream (quoteId VARCHAR,
count INT)
WITH (KAFKA_TOPIC='KQUOTE',
VALUE_FORMAT='JSON',
KEY='quoteId');
I expect above use RAWKEY quoteId, but it's not. As we can see below the RAWKEY is always 1(since we group by constant 1 when creating table kquote).
ksql> select * from KQuoteStream;
1574121797111 | 1 | 806 | 20
1574121979291 | 1 | 807 | 21
Try to re partition the stream by quoteId to change RAWKEY to be quoteId
CREATE stream KQuoteStreamByQuoteId
as
SELECT quoteId, COUNT FROM KQuoteStream PARTITION BY quoteId;
RAMKEY is still constant 1
ksql> select * from KQuoteStreamByQuoteId;
1574121797111 | 1 | 806 | 20
1574121979291 | 1 | 807 | 21
BTW: All topic has same partition as 1 to make things simpler. Anyone has some idea? Thanks a lot !