これを試すと:
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 = lines.groupBy('value').count()
query = words.writeStream.format('console').outputMode("complete").start()
query.awaitTermination()
次に、エラーが発生します:
AssertionError: dataType は DataType である必要があります
そして、./pyspark/sql/types.py の 403 行目でソース コードを検索します。
assert isinstance(dataType, DataType), "dataType should be DataType"
ただし、DataTypeではなくAtomicTypeに基づくStringType
class StringType(AtomicType):
"""String data type.
"""
__metaclass__ = DataTypeSingleton
それで、間違いはありますか?