Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

python - Error Stream metadata using Pyspark in Windows 10 OS

I am trying to stream the data from Twitter API but unable to execute the code.

Following are the code snippet and error. Please let me know what is the issue if anyone can help here.

Code:

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

Error:

Error : ERROR StreamMetadata: Error writing stream metadata StreamMetadata(ea206b0f-718b-49f5-bd97-9e7488f643cd) to file:/C:/Users/aakash%2520uppadhaya/AppData/Local/Temp/temporary-41057c59-fcac-4d2e-9a71-a6e53c57c2ec/metadata java.io.FileNotFoundException: File file:/C:/Users/aakash%2520uppadhaya/AppData/Local/Temp/temporary-41057c59-fcac-4d2e-9a71-a6e53c57c2ec does not exist

question from:https://stackoverflow.com/questions/65864887/error-stream-metadata-using-pyspark-in-windows-10-os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...