ksql> CREATE TABLE HOPPING_TABLE AS SELECT ID, WINDOWSTART() AS WINSTART, COUNT(*) AS CNT FROM MY_STREAM HOPPING WINDOW (SIZE 30 DAYS, ADVANCED BY 1 DAYS) GROUP BY ID;
ksql> SELECT ID, WINSTART, CNT FROM HOPPING_TABLE;
id winstart cnt
-------------------------------------------
874163197805291909 1547164800000 23
874163197805291909 1547424000000 11
874163197805291909 1547510400000 26
874163197805291909 1547683200000 12
660071199310134801 1545868800000 6
660071199310134801 1546560000000 7
660071199310134801 1547251200000 3
现在,我只关心每个ID
分组的具有最大winstart值的window的cnt,那么如何通过KSQL实现呢?
考虑到上面的示例(将2个ID分组),希望从上面的HOPPING TABLE生成具有以下记录的表:
id winstart cnt
-------------------------------------------
874163197805291909 1547683200000 12
660071199310134801 1547251200000 3