Apache spark spark中用于添加新列的withcolumn()未显示结果
我正在尝试使用withcolumn添加一个新列,其值应为NULL,但不起作用Apache spark spark中用于添加新列的withcolumn()未显示结果,apache-spark,apache-spark-sql,apache-spark-dataset,Apache Spark,Apache Spark Sql,Apache Spark Dataset,我正在尝试使用withcolumn添加一个新列,其值应为NULL,但不起作用 val schema = StructType( StructField("uid",StringType,true):: StructField("sid",StringType,true):: StructField("astid",StringType,true)::
val schema = StructType(
StructField("uid",StringType,true)::
StructField("sid",StringType,true)::
StructField("astid",StringType,true)::
StructField("timestamp",StringType,true)::
StructField("start",StringType,true)::
StructField("end",StringType,true)::
StructField("geo",StringType,true)::
StructField("stnid",StringType,true)::
StructField("end_type",LongType,true)::
StructField("like",LongType,true)::
StructField("dislike",LongType,true)::Nil
)
val Mobpath = spark.read.schema(schema).csv("/data/mob.txt")
Mobpath.printSchema()
Mobpath.createOrReplaceTempView("Mobpathsql")
val showall = spark.sql("select * from Mobpathsql")
showall.show()
val newcol = Mobpath.withColumn("new1",functions.lit("null"))
newcol.show()
将与列一起使用
不会显示任何错误,也不会显示任何输出。这是怎么回事:
val newcol = showall.withColumn("new1",functions.lit("null"))
newcol.show()
我只是测试了上面的代码,它成功了,我不知道为什么它不能与Mobpath一起工作,它对我有效,所以我认为其他评论可能是有效的,但我有一些数据。我不确定我是否得到了问题或答案。添加了更多详细信息