Create new Dataframe with empty/null field values
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am creating a new Dataframe from an existing dataframe, but need to add new column ("field1" in below code) in this new DF. How do I do so? Working sample code example will be appreciated. val edwDf = omniDataFrame . withColumn ( "field1" , callUDF (( value : String ) => None )) . withColumn ( "field2" , callUdf ( "devicetypeUDF" , ( omniDataFrame . col ( "some_field_in_old_df" )))) edwDf . select ( "field1" , "field2" ) . save ( "odsoutdatafldr" , "com.databricks.spark.csv" ); 回答1: It is possible to use lit(null) : import org .