我对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中没有第 2 行时结果中的"hello"是如何产生的
我不确定您的查询在没有on
子句的情况下如何工作。 但是,您可以使用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;