Spark 创建有schema的空dataframe

var DFSchema : StructType = (new StructType)
List("xx1","xx2","xx3").foreach(colname=> DFSchema = DFSchema.add(colname,StringType,true))
if(DF.isEmpty){
  DF = spark.createDataFrame(spark.sparkContext.emptyRDD[Row], DFSchema)
}

你可能感兴趣的:(spark,spark,scala)