Spark结构化流:水印不起作用,状态未清除

时间:2018-08-06 11:10:46

标签: spark-structured-streaming

我正在使用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();

0 个答案:

没有答案