在使用imageinstring
连接到kafka主题spark.readStream
的过程中,我遇到了此错误:
Py4JJavaError: An error occurred while calling o49.load.
: java.lang.NoClassDefFoundError:
org/apache/spark/sql/sources/v2/reader/SupportsScanUnsafeRow
我正在使用:
具有以下依赖性:
org.apache.spark:spark-streaming-kafka-0-8_2.11:2.4.5
org.apache.spark:spark-sql-kafka-0-10_2.11:2.4.5
这是我的代码:
import findspark
findspark.init()
# Spark
from pyspark.sql import SparkSession
# Spark Streaming
from pyspark.streaming import StreamingContext
# Kafka
from pyspark.streaming.kafka import KafkaUtils
# json parsing
import json
spark = SparkSession.builder.appName("StructuredNetwork").getOrCreate()
df=spark.readStream.format("kafka")\
.option("kafka.bootstrap.servers","localhost:9092")\
.option("subscribe","imageinstring").load()
query = df.writeStream.outputMode("complete").format("console").start()
query.awaitTermination()