Apache spark SPARK结构化流媒体中的StructField是否存在缺陷

Apache spark SPARK结构化流媒体中的StructField是否存在缺陷,apache-spark,pyspark,apache-spark-sql,spark-structured-streaming,Apache Spark,Pyspark,Apache Spark Sql,Spark Structured Streaming,当我尝试这个: cfg=SparkConf().setAppName('MyApp') spark=SparkSession.builder.config(conf=cfg).getOrCreate() lines=spark.readStream.load(format='socket',host='localhost',port=9999, schema=StructType(StructField('value',StringType,True))) words=行。groupBy('va

当我尝试这个:

cfg=SparkConf().setAppName('MyApp')
spark=SparkSession.builder.config(conf=cfg).getOrCreate()
lines=spark.readStream.load(format='socket',host='localhost',port=9999,
schema=StructType(StructField('value',StringType,True)))
words=行。groupBy('value')。count()
query=words.writeStream.format('console').outputMode(“complete”).start()
查询
然后我得到了一些错误:

AssertionError:数据类型应为数据类型

我在第403行的./pyspark/sql/types.py中搜索源代码:

assert isinstance(dataType, DataType), "dataType should be DataType"
但是StringType基于AtomicType而不是DataType

类StringType(原子类型):
“”“字符串数据类型。
"""
__元类\数据类型单例

那么有错误吗?

在Python中,数据类型不作为单例使用。创建
StructField
时,必须使用实例。另外,
StructType
需要一系列的
StructField

StructType([StructField('value',StringType(),True)])
然而,这在这里是完全没有意义的。带有模式参数的
TextSocketSource
的模式