Spark:数据中有null值时的group结果
数据中有null值时的group结果:
Seq(("a", new BigDecimal(1.2)), ("a", null), (null, new BigDecimal(1.2)), (null, new BigDecimal(1.2)) ).toDF("a", "v")
res20.show
/*
+----+--------------------+
| a| v|
+----+--------------------+
| a|1.199999999999999956|
| a| null|
|null|1.199999999999999956|
|null|1.199999999999999956|
+----+--------------------+
*/
res20.groupBy("a").sum("v").show
/*
+----+--------------------+
| a| sum(v)|
+----+--------------------+
|null|2.399999999999999912|
| a|1.199999999999999956|
+----+--------------------+
*/