Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark 从Spark数据帧中删除空白字段_Apache Spark_Apache Kafka_Apache Spark Sql_Spark Structured Streaming - Fatal编程技术网

Apache spark 从Spark数据帧中删除空白字段

Apache spark 从Spark数据帧中删除空白字段,apache-spark,apache-kafka,apache-spark-sql,spark-structured-streaming,Apache Spark,Apache Kafka,Apache Spark Sql,Spark Structured Streaming,我使用spark structured streaming来使用kafka主题,该主题有几种类型的消息(每种类型的模式不同)。我定义了一个模式,其中包含不同类型消息的所有字段。 如何从每行的dataframe中筛选空字段,或者如何使用动态模式从kafka中读取dataframe val inputDS=spark .readStream .格式(“卡夫卡”) .option(“kafka.bootstrap.servers”,“localhost:9092”) .期权(“认购”、“概述”) .l

我使用spark structured streaming来使用kafka主题,该主题有几种类型的消息(每种类型的模式不同)。我定义了一个模式,其中包含不同类型消息的所有字段。
如何从每行的dataframe中筛选空字段,或者如何使用动态模式从kafka中读取dataframe

val inputDS=spark
.readStream
.格式(“卡夫卡”)
.option(“kafka.bootstrap.servers”,“localhost:9092”)
.期权(“认购”、“概述”)
.load()
val schemaa:StructType=StructType(
排列(
StructField(“标题”,StringType,true),
StructField(“url”,StringType,true),
StructField(“内容”,StringType,true),
StructField(“收集时间”,StringType,true),
StructField(“时间”,StringType,true),
StructField(“用户头”,StringType,true),
StructField(“图像”,StringType,true)
)
)
inputDS.withColumn(“value”,来自_json($“value”.cast(StringType),schemaa))
//.filter()//todo筛选器空字段
.writeStream
.格式(“控制台”)
.start()
.终止

不能从行中删除单个列。也许可以将它从Kafka读入RDD,找出消息类型,并将其移动到正确模式的数据帧中。@Andrew非常感谢。我已经启用了alreday,将它从Kafka读入RDD,我想将它从spark流媒体升级到spark结构化流媒体。