【问题标题】:Why an exception while writing an aggregated dataframe to a file sink?为什么将聚合数据帧写入文件接收器时出现异常?
【发布时间】:2020-11-01 10:08:29
【问题描述】:

我正在对流数据帧执行聚合并尝试将结果写入输出目录。但我得到一个例外说

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()

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-04
      • 2017-05-16
      • 1970-01-01
      • 1970-01-01
      • 2013-06-13
      • 2016-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多