窗口开始时间反映在
ROWTIME
在ksql消息的时间戳中。这个时间戳您可以使用用于处理kafka消息的标准api来访问。
阿飞
kafka-console-consumer
不支持显示时间戳。不管怎样
kafkacat
做。
下面是ksql中的一些聚合数据,其中
划线时间
显示窗口的开始(和
TIMESTAMPTOSTRING
习惯了漂亮的印刷品):
ksql> SELECT TIMESTAMPTOSTRING(ROWTIME, 'yyyy-MM-dd HH:mm:ss'), ROWTIME, STARS, STAR_COUNT FROM RATINGS_AGG2;
2018-06-27 09:30:00 | 1530091800000 | 1 | 2
2018-06-27 09:30:00 | 1530091800000 | 4 | 6
2018-06-27 09:30:00 | 1530091800000 | 2 | 2
2018-06-27 09:30:00 | 1530091800000 | 3 | 3
现在同一个话题
卡夫卡
:
$ kafkacat -b localhost:9092 -C -K: \
-f '\nTimestamp: %T\t\tValue (%S bytes): %s' \
-t RATINGS_AGG2
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":1,"STARS":1}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":2,"STARS":1}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":3,"STARS":3}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":5,"STARS":1}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":6,"STARS":3}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":7,"STARS":1}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":7,"STARS":3}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":9,"STARS":1}
Timestamp: 1530091800000 Value (26 bytes): {"STAR_COUNT":9,"STARS":3}