我正在使用Spark v.3.2.1 Java库。我正在将groupBy
功能与水印一起使用。
似乎.withWatermark
无法正常工作。发送“太迟”的事件不会被丢弃。另外,我注意到状态文件夹没有被清理。下面是我使用的代码。有人可以找出问题所在吗?
Dataset<WindowEvent> aggDs = dataset
.withWatermark(TIMESTAMP_COLUMN, "10 minutes")
.groupBy(functions.window(dataset.col(TIMESTAMP_COLUMN), windowDuration), dataset.col(COUNTRY_ID_COLUMN))
.agg(collect_list("city"))
.toDF("window", COUNTRY_ID_COLUMN, "cities")
.as(Encoders.bean(WindowEvent.class));
StreamingQuery queue = aggDs
.writeStream()
.option("checkpointLocation", checkPointLocation)
.outputMode(OutputMode.Update())
.foreach(new MyCustomForEachWriter())
.start();
queue.awaitTermination();