Apache spark 将Spark SQL批处理源转换为结构化流接收器
试图将Apache spark 将Spark SQL批处理源转换为结构化流接收器,apache-spark,apache-spark-sql,spark-structured-streaming,Apache Spark,Apache Spark Sql,Spark Structured Streaming,试图将org.apache.spark.sql.sources.createablerelationprovider转换为org.apache.spark.sql.execution.streaming.Sink,只需实现调用createRelation(…)的addBatch(…),但createRelation(…)中有一个df.rdd,这将导致以下错误: org.apache.spark.sql.catalyst.analysis.UnsupportedOperationChecker$.
org.apache.spark.sql.sources.createablerelationprovider
转换为org.apache.spark.sql.execution.streaming.Sink
,只需实现调用createRelation(…)
的addBatch(…)
,但createRelation(…)
中有一个df.rdd
,这将导致以下错误:
org.apache.spark.sql.catalyst.analysis.UnsupportedOperationChecker$.org$apache$spark$sql$catalyst$analysis$UnsupportedOperationChecker$$throwError(UnsupportedOperationChecker.scala:374)
我们试图研究在流作业中如何从dataframe获取Rdd的org.apache.spark.sql.execution.streaming.FileStreamSink
,它似乎在使用df.queryExecution.executePlan.execute()
生成Rdd,而不是调用.Rdd
然而事情似乎并不是那么简单:
Dataset.rdd()
创建了一个新的计划,它打破了增量计划。由于StreamExecution使用现有计划收集指标并更新水印,因此我们不应创建新计划。否则,度量和水印将在新计划中更新,StreamExecution无法检索它们
下面是Scala中用于在结构化流媒体中转换列值的代码示例:
val convertedRows:RDD[Row]=df.queryExecution.toRdd.mapPartitions{iter:Iterator[InternalRow]=>
iter.map{row=>
val convertedValues:Array[Any]=新数组(conversionFunctions.length)
变量i=0
while(i