Artsiom Yudovin
11/26/2024, 6:38 PMtableEnv.executeSql("CREATE TABLE actionTable ("
+ " id BIGINT,"
+ " user_uuid STRING,"
+ " create_at ROWseconds BIGINT, nanos INT,"
+ " event_time AS TO_TIMESTAMP(FROM_UNIXTIME(create_at.seconds)),"
+ " WATERMARK FOR event_time AS event_time - INTERVAL '1' MINUTES"
+ ") WITH ("
+ " 'connector' = 'kafka',"
+ " 'topic' = 'test',"
+ " 'properties.group.id' = 'testGroup',"
+ " 'properties.bootstrap.servers' = 'localhost:9092',"
+ " 'format' = 'protobuf',"
+ " 'protobuf.message-class-name' = 'clickstream.EventRequest',"
+ " 'scan.startup.mode' = 'earliest-offset'"
+ ")");
}
My data is:
+----+----------------------+-------------------------+--------------------------------+--------------------------------+
| op | id | event_time | user_uuid | create_at |
+----+----------------------+-------------------------+--------------------------------+--------------------------------+
| +I | 1 | 2024-11-25 10:53:00.000 | user_uuid | (1732528380, 648000000) |
| +I | 1 | 2024-11-25 12:56:02.000 | user_uuid | (1732535762, 118000000) |
| +I | 1 | 2024-11-26 16:51:36.000 | user_uuid | (1732636296, 68000000) |
| +I | 1 | 2024-11-26 16:51:46.000 | user_uuid | (1732636306, 350000000) |
| +I | 1 | 2024-11-26 18:28:13.000 | user_uuid | (1732642093, 450000000) |
| +I | 1 | 2024-11-26 18:39:33.000 | user_uuid2 | (1732642773, 437000000) |
| +I | 1 | 2024-11-26 19:14:47.000 | user_uuid2 | (1732644887, 335000000) |
My code is
env.enableCheckpointing(15000);
final var tableEnv = StreamTableEnvironment.create(env);
tableEnv.getConfig().set("table.exec.emit.default.watermark", "true");
generateUserActions(tableEnv);
Table table = tableEnv.sqlQuery("Select id, event_time, user_uuid, create_at from actionTable");
var w = Tumble.over(lit(1).minutes()).on($("event_time")).as("w");
var result = table.window(w)
.groupBy($("user_uuid"), $("w")).select($("user_uuid"), $("id").count(), $("w").end());
result.execute().print();
I can not understand why it’s not printing anything