为什么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