【发布时间】:2018-12-09 23:54:29
【问题描述】:
我有一个特殊的用例,我有多个行用于同一客户,每个行对象看起来像:
root
-c1: BigInt
-c2: String
-c3: Double
-c4: Double
-c5: Map[String, Int]
现在我已经按列 c1 进行分组,并将所有行收集为同一客户的列表,例如:
c1, [Row1, Row3, Row4]
c2, [Row2, Row5]
我试过这样做
dataset.withColumn("combined", array("c1","c2","c3","c4","c5")).groupBy("c1").agg(collect_list("combined")) 但我得到一个例外:
Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot resolve 'array(`c1`, `c2`, `c3`, `c4`, `c5`)' due to data type mismatch: input to function array should all be the same type, but it's [bigint, string, double, double, map<string,map<string,double>>];;
【问题讨论】:
-
你是在建议元组吗?你能帮我举个例子吗。我也只想将它们收集为 Rows 对象。
-
这是我的错。请粘贴您的测试数据。会检查
标签: java scala apache-spark apache-spark-sql spark-streaming