解决NION‘. Failed rule- ‘orderByClause clusterByClause distributeByClause sortByClause limitClause can

解决NION‘. Failed rule- ‘orderByClause clusterByClause distributeByClause sortByClause limitClause canUNION Failed rule orderByClaus clusterByCla distributeBy sortByClause limitClause can only be applied to the whole union in statement hive 中是不支持上面的这种查询的 但是在 impala 中是支持的 我表示很抑郁

大家好,我是讯享网,很高兴认识大家。

‘UNION’. Failed rule: ‘orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.’ in statement

在这里插入图片描述
讯享网
hive中是不支持上面的这种查询的
但是在impala中是支持的

在这里插入图片描述
我表示很抑郁
由于我写的sql是要放到脚本里面的
因为impala也是可以用写sql到脚本的中的
确实可以解决这个办法

解释一下

union

相同点 是 相当于上下拼接 上下两个拼接表必须字段保持一致

不同 union有去重效果,速度会更慢。

union all的子句里不支持orderByClause、clusterByClause、distributeByClause、sortByClause或limitClause

其实在上面的sql要做改变就可以的

SELECT '-998' distinct_id, itemid, itemtypeid, isfreeview FROM t_item_info_tmp WHERE itemtypeid=14 AND isfreeview=1 LIMIT 10 UNION ALL SELECT '-998' distinct_id, itemid, itemtypeid, isfreeview FROM t_item_info_tmp WHERE itemtypeid=14 AND isfreeview=0 LIMIT 10 

讯享网

这种方式是错的,在hive上是不能运行的

讯享网SELECT * from (SELECT '-998' distinct_id, itemid, itemtypeid, isfreeview FROM t_item_info_tmp WHERE itemtypeid=14 AND isfreeview=1 ORDER BY rand() LIMIT 100)h UNION ALL select * from ( SELECT '-998' distinct_id, itemid, itemtypeid, isfreeview FROM t_item_info_tmp WHERE itemtypeid=14 AND isfreeview=0 ORDER BY rand() LIMIT 100)i 

在这里插入图片描述
这种方式就是可以的
完美的了
哈哈

小讯
上一篇 2025-03-26 17:26
下一篇 2025-03-12 12:45

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/84693.html