2016-12-27 38 views
2

在运行流的节目指南[链接] Python的火花结构给出的例子
http://spark.apache.org/docs/latest/structured-streaming-programming-guide.html类型错误:“生成器”的对象是不可调用的星火结构流

我得到以下错误:
类型错误:“生成器'对象不是可调用

from pyspark.sql import SparkSession 
from pyspark.sql.functions import explode 
from pyspark.sql.functions import split 

spark = SparkSession.builder()\ 
    .appName("StructuredNetworkWordCount")\ 
    .getOrCreate() 

# Create DataFrame representing the stream of input lines from connection to localhost:9999 
lines = spark\ 
    .readStream\ 
    .format('socket')\ 
    .option('host', 'localhost')\ 
    .option('port', 9999)\ 
    .load() 

# Split the lines into words 
words = lines.select(
    explode(
     split(lines.value, ' ') 
    ).alias('word') 
) 

# Generate running word count 
wordCounts = words.groupBy('word').count() 

# Start running the query that prints the running counts to the console 
query = wordCounts\ 
    .writeStream\ 
    .outputMode('complete')\ 
    .format('console')\ 
    .start() 

query.awaitTermination() 

错误:

[email protected]:~/thesis/backUp$ spark-submit structured.py 
Traceback (most recent call last): 
    File "/home/omkar/thesis/backUp/structured.py", line 8, in <module> 
    spark = SparkSession.builder()\ 
TypeError: 'Builder' object is not callable 

回答

相关问题