【发布时间】:2018-11-04 09:07:50
【问题描述】:
我正在尝试使用 withcolumn 添加一个新列,其值应该为 NULL 但它不起作用。
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()
使用withcolumn 没有显示任何错误,也没有显示任何输出。
【问题讨论】:
-
它对我有用,所以我认为其他评论可能是有效的,但我有一些数据。
标签: apache-spark apache-spark-sql apache-spark-dataset