配置单元按不可见列排序 [英] Hive order by not visible column

查看:47
本文介绍了配置单元按不可见列排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的表test的列为a,b,而ctest2的列相同.我可以创建表测试的视图并将测试2连接在一起并按表测试中的字段c排序,而不在最终输出中显示它吗?就我而言:

Let's say I have table test with column a,b and c and test2 with same column. Can I create a view of table test and test 2 joined together and ordered by field c from table test without showing it in final output? In my case:

CREATE VIEW AS test_view AS
SELECT a,b FROM (SELECT * FROM test ORDER BY c)
JOIN test2 ON test.a =test2.a;

好吧,我测试了它,因为混洗阶段是不可能的,所以也许有另一种解决方案吗?表太大,无法进行广播连接.

Ok I test it and it is not possible because shuffle phase so maybe there is another solution to somehow do it? Table are too big to do broadcast join.

我当然可以

CREATE VIEW AS test_view AS
SELECT a,b,c FROM test
JOIN test2 ON test.a =test2.a
ORDER BY c

然后

CREATE VIEW AS final_view AS
SELECT a,b FROM test_view;

但是这种解决方案不是最优的

But this solution is very not optimal

有什么主意吗?

推荐答案

这是您正在寻找的东西吗?

Is this what you are looking at?

CREATE VIEW AS test_view AS
SELECT a,b FROM 
(SELECT * FROM 
test t1 JOIN test2 t2
ON test.a =test2.a
ORDER BY t1.c
) abc;

这篇关于配置单元按不可见列排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆