火花结构化流databrick上没有控制台输出

发布于 2025-02-12 17:26:07 字数 1281 浏览 1 评论 0 原文

我正在尝试将带有套接字的Databrick中的结构化流作为源,并将控制器作为输出接收器。

但是,我无法在Databrick上看到任何输出。

from pyspark.sql.functions import *

lines = (spark
  .readStream.format("socket")
  .option("host", "localhost")
  .option("port", 9999)
  .load())

countdf = lines.select(split(col("value"), "\\s").alias("word")).groupBy("word").count()

checkpointDir = "/tmp/streaming"
streamingQuery = (countdf
  .writeStream
  .format("console")
  .outputMode("complete")
  .trigger(processingTime="1 second")
  .option("checkpointLocation", checkpointDir)
  .start())

在另一个终端中,通过套接字

我看不到仪表板中的任何更新/更改,也没有显示输出。当我尝试显示countdf时,它显示 AnalySiseXception:必须使用Writestream.start();

.png“ rel =“ nofollow noreferrer”> “在此处输入图像说明”

I am trying to use structured streaming in databrick with socket as source, and console as the output sink.

However, I am not able to see any output on databrick.

from pyspark.sql.functions import *

lines = (spark
  .readStream.format("socket")
  .option("host", "localhost")
  .option("port", 9999)
  .load())

countdf = lines.select(split(col("value"), "\\s").alias("word")).groupBy("word").count()

checkpointDir = "/tmp/streaming"
streamingQuery = (countdf
  .writeStream
  .format("console")
  .outputMode("complete")
  .trigger(processingTime="1 second")
  .option("checkpointLocation", checkpointDir)
  .start())

enter image description here

In another terminal, send data via socket

enter image description here

I am not able to see any updates/changes in the dashboard, and there is no output shown. When I try to show the countdf, it is showing AnalysisException: Queries with streaming sources must be executed with writeStream.start();

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤蝉 2025-02-19 17:26:07

您不能在流媒体查询上使用 .show 。另外,在 console 输出的情况下,它将其打印到日志中,而不是笔记本中。如果您只想查看转换的结果,则可以在数据映中使用 display 函数支持流数据集的可视化,包括用于检查点位置的设置&触发间隔

You can't use .show on the streaming queries. Also, in the case of the console output, it's printed into logs, not into the notebook. If you just want to see the results of your transformations, on Databricks you can use display function that supports visualization of streaming datasets, including settings for checkpoint location & trigger interval.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文