在 Windows 10 操作系统中使用 Pyspark 的错误流元数据

问题描述

我正在尝试从 Twitter API 流式传输数据,但无法执行代码

以下是代码片段和错误。如果有人可以在这里提供帮助,请告诉我是什么问题。

代码

from pyspark.sql import SparkSession
from pyspark.sql.functions import *
from pyspark.sql.types import *
from pyspark.sql import functions as F


if __name__ == "__main__":

    # create Spark session
    spark = SparkSession.builder.appName("TwitterSentimentAnalysis").getorCreate()

    # read the tweet data from socket
    tweet_df = spark \
        .readStream \
        .format("socket") \
        .option("host","127.0.0.1") \
        .option("port",3333) \
        .load()

    # type cast the column value
    tweet_df_string = tweet_df.selectExpr("CAST(value AS STRING)")


    # split words based on space,filter out hashtag values and group them up
    tweets_tab = tweet_df_string.withColumn('word',explode(split(F.col('value'),' '))) \
        .groupBy('word') \
        .count() \
        .sort('count',ascending=False). \
        filter(F.col('word').contains('#'))



    # write the above data into memory. consider the entire analysis in all iteration (output mode = complete). and let the trigger runs in every 2 secs.
    writeTweet = tweets_tab.writeStream\
    .outputMode('complete')\
    .format('console')\
    .start()

    print("----- streaming is running -------")

错误

错误错误流元数据:写入流元数据时出错 流元数据(ea206b0f-718b-49f5-bd97-9e7488f643cd)到 文件:/C:/Users/aakash%2520uppadhaya/AppData/Local/Temp/temporary-41057c59-fcac-4d2e-9a71-a6e53c57c2ec/Metadata java.io.FileNotFoundException:文件文件:/C:/Users/aakash%2520uppadhaya/AppData/Local/Temp/temporary-41057c59-fcac-4d2e-9a71-a6e53c57c2ec 不存在

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)