对于Hive上的sparksql,当我使用 named_struct
在查询中,它返回结果:
SELECT id, collect_set(emp_info) as employee_info
FROM
(
SELECT t.id, named_struct("name", t.emp_name, "dept", t.emp_dept) AS emp_info
FROM mytable t
) a
GROUP BY id
但当我换了 named_struct
与 map
,我得到一个错误:
SELECT id, collect_set(emp_info) as employee_info
FROM
(
SELECT t.id, map("name", t.emp_name, "dept", t.emp_dept) AS emp_info
FROM mytable t
) a
GROUP BY id
ERROR yarn.ApplicationMaster: User class threw exception: org.apache.spark.sql.AnalysisException: cannot resolve 'collect_set(a.`emp_info`)' due to data type mismatch: collect_set() cannot have map type data; line 36 pos 27;
'Distinct
我想还一张Map name
以及 dept
,如何与 collect_set
? 仅供参考:此查询包含 map
在配置单元中运行而没有问题(色调)
暂无答案!
目前还没有任何答案,快来回答吧!