我使用 Spark 2.0.1 Scala 2.11
如何使用提供默认值coalesce
对于一个列来说StructType
?
Say ...
val ss = new StructType().add("x", IntegerType).add("y", IntegerType)
val s = new StructType()
.add("a", IntegerType)
.add("b", ss)
val d = Seq( Row(1, Row(1,2)), Row(2, Row(2,3)), Row(2, null) )
val rd = sc.parallelize(d)
val df = spark.createDataFrame(rd, s)
Now, df.select($"b").show
结果是
+-----+
| b |
+-----+
|[1,2]|
|[2,3]|
| null|
+-----+
我的问题是如何提供默认值(比如[0,0]
) using coalesce
?