为什么将聚合数据帧写入文件接收器时发生异常?

时间:2020-11-01 10:08:29

标签: apache-spark pyspark apache-spark-sql spark-structured-streaming

我正在对流数据帧执行聚合,并尝试将结果写入输出目录。但是我听到一个异常的说法

pyspark.sql.utils.AnalysisException: 'Data source json does not support Update output mode;

在“完整”输出模式下,我收到类似的错误消息。

这是我的代码:

grouped_df = logs_df.groupBy('host', 'timestamp').agg(count('host').alias('total_count'))
 
result_host = grouped_df.filter(col('total_count') > threshold)
 
writer_query = result_host.writeStream \
    .format("json") \
    .queryName("JSON Writer") \
    .outputMode("update") \
    .option("path", "output") \
    .option("checkpointLocation", "chk-point-dir") \
    .trigger(processingTime="1 minute") \
    .start()

writer_query.awaitTermination()

1 个答案:

答案 0 :(得分:2)

根据OutputSinks上的文档,FileSinks仅支持“附加”模式,请参阅下表中的“支持的输出模式”。

enter image description here