[解决办法] Cannot have map type columns in DataFrame which calls set operations(intersect, except, etc.)

[解决办法] Sql执行错误:org.apache.spark.sql.AnalysisException: Cannot have map type columns in DataFrame which calls set operations(intersect, except, etc.), but the type of column extend_value is map<string,string>

原始语句

select distinct id
	, cols
	, extend_value 
from test.test_table 

报错信息

Sql执行错误:org.apache.spark.sql.AnalysisException: Cannot have map type columns in DataFrame which calls set operations(intersect, except, etc.), but the type of column extend_value is map<string,string>;; 

尝试 group by 解决

select id
	, cols
	, extend_value 
from test.test_table
group by id, cols, extend_value

依旧报错

Sql执行错误:org.apache.spark.sql.AnalysisException: expression test_table.`extend_value` cannot be used as a grouping expression because its data type map<string,string> is not an orderable data type.;; 

解决方案

方案一 分片排序后取第一条

select id
	, cols
	, extend_value 
from (
	select id
		, cols
		, extend_value 
		, row_number() over (partition by id, order by cols) as row_num
	from test.test_table )
where row_num = 1

方案二(待加入)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Sinsa_SI

您的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值