首页 > 解决方案 > checkpointLocation 需要正确的 hdfs 路径

问题描述

我是 Spark 的新手。

我尝试使用流。

我写了以下代码:

streaming_query = input_df.groupBy("sensor_id").count().writeStream \
                          .format("console") \
                          .outputMode("update") \
                          .option("timestampFormat", "YYYY-mm-dd HH:MM:SS") \
                          .option("checkpointLocation", os.path.join(basepath, "Spark-Streaming-Demo")) \
                          .trigger(processingTime="1 second") \
                          .start()
streaming_query.awaitTermination()

但是,在运行这段代码时,我收到错误消息:

java.lang.IllegalStateException: Error reading delta file file:/path/on/local-system/state/0/0/1.delta of HDFSStateStoreProvider[id = (op=0,part=0),dir = file:/path/on/local-system/state/0/0]: file:/path/on/local-system/state/0/0/1.delta does not exist

我认为checkpointLocation应该是 HDFS 文件路径而不是本地绝对路径。

如何找出 HDFS URI 的os.path.join(basepath, "Spark-Streaming-Demo")

标签: pysparkhdfsspark-structured-streaming

解决方案


推荐阅读