我对Hive相对较新。探索合并两个未通过键相互连接的表的方法。所以,我没有在查询中使用'ON'条件。
以下是table_1:
COL1
hello
以下是table_2:
COL2
world
excellent
预期结果:
hello world
NULL excellent
实际结果:
hello world
hello excellent
我的查询:
select col_one,
col_two
from (
select COL1 as col_one
from table_1
) as c1
join (
select COL2 as col_two
from table_2
) as c2;
我不确定当table_1中没有第二行时,结果中的“你好”如何出现
答案 0 :(得分:0)
如果没有row_number()
子句,我不确定您的查询是如何工作的。但是,您可以使用select c1.col_one, c2.col_two
from (select COL1 as col_one, row_number() over (order by col1) as seqnum
from table_1
) c1 join
(select COL2 as col_two, row_number() over (order by col2) as seqnum
from table_2
) c2
on c1.seqnum = c2.seqnum;
执行您想要的操作,如下所示:
settings.py