【发布时间】:2022-10-09 04:59:19
【问题描述】:
我的操作系统是 Windows 11,Apache Spark 版本是spark-3.1.3-bin-hadoop3.2
我尝试将 Spark 结构化流与 pyspark 一起使用。下面是我简单的 spark 结构化流代码。
spark = SparkSession.builder.master("local[*]").appName(appName).getOrCreate()
spark.sparkContext.setCheckpointDir("/C:/tmp")
没有spark.sparkContext.setCheckpointDir 行的相同 Spark 代码在 Ubuntu 22.04 上不会引发错误。但是,上述代码在 Windows 11 上无法成功运行。例外情况是
pyspark.sql.utils.IllegalArgumentException: Pathname /C:/tmp/67b1f386-1e71-4407-9713-fa749059191f from C:/tmp/67b1f386-1e71-4407-9713-fa749059191f is not a valid DFS filename.
我认为错误代码意味着检查点目录是在 Linux 的 Hadoop 文件系统上生成的,而不是在 Windows 11 上。我的操作系统是 Windows,检查点目录应该是 Windows 11 本地目录。如何使用 Windows 11 本地目录配置 Apache Spark 检查点?我使用file:///C:/temp 和hdfs://C:/temp URL 进行测试。但是仍然抛出错误。
更新
我将下面的行设置为 cmets。
#spark.sparkContext.setCheckpointDir("/C:/tmp")
然后抛出异常。
WARN streaming.StreamingQueryManager: Temporary checkpoint location created which is deleted normally when the query didn't fail: C:\Users\joseph\AppData\Local\Temp\temporary-be4f3586-d56a-4830-986a-78124ab5ee74. If it's required to delete it under any circumstances, please set spark.sql.streaming.forceDeleteTempCheckpointLocation to true. Important to know deleting temp checkpoint folder is best effort.
pyspark.sql.utils.IllegalArgumentException: Pathname /C:/Users/joseph/AppData/Local/Temp/temporary-be4f3586-d56a-4830-986a-78124ab5ee74 from hdfs://localhost:9000/C:/Users/joseph/AppData/Local/Temp/temporary-be4f3586-d56a-4830-986a-78124ab5ee74 is not a valid DFS filename.
我想知道为什么 hdfs url 包含c:/ 驱动程序字母,我想知道如何将spark.sql.streaming.forceDeleteTempCheckpointLocation 设置为true。
【问题讨论】:
标签: pyspark spark-structured-streaming spark-checkpoint