小编T. *_*eke的帖子

为什么变换在结构化流中只进行一次副作用(println)?

为什么select声明是每批打印的,但hello world只打印一次?

import org.apache.spark.sql.types._
val schema = StructType(
  StructField("id", LongType, nullable = false) ::
  StructField("name", StringType, nullable = false) ::
  StructField("score", DoubleType, nullable = false) :: Nil)

val in: DataFrame = sparkSession.readStream
 .schema(schema)
 .format("csv")
 .option("header", false)
 .option("maxFilesPerTrigger", 1)
 .option("delimiter", ";")
 .load("s3://xxxxxxxx")

val input: DataFrame = in.select("*")
 .transform { ds =>
   println("hello world")  // <-- Why is this printed out once?
   ds
}

import org.apache.spark.sql.streaming.StreamingQuery
val query: StreamingQuery = input.writeStream
  .format("console")
  .start
Run Code Online (Sandbox Code Playgroud)

scala apache-spark apache-spark-sql spark-structured-streaming

5
推荐指数
1
解决办法
255
查看次数