【发布时间】:2021-07-23 09:37:24
【问题描述】:
也许有人知道 Hive 中左连接问题的答案。
1.假设我有:
table A.c1 table A.c2 table B.c1 table B.c2 table B.c3
2021-05 1701 2021-05 1701 May 5
2021-06 1701 2021-06 1701 June 7
2021-07 1701
2.当我使用像这样的脚本时
select table A.* , table B.c3
from table A left join table B
on table A.c1 = table B.c1 and table A.c2 = table B.c2
3.Hive 将返回
table C.c1 table C.c2 table C.c3
2021-05 1701 May 5
2021-06 1701 June 7
4.但我想以某种方式得到这个结果(因为我记得“左连接”在 MS SQL 中是这样工作的)
table C.c1 table C.c2 table C.c3
2021-05 1701 May 5
2021-06 1701 June 7
2021-07 1701 NULL
我的脚本是正确的还是做这样的结果不是那么简单?
【问题讨论】:
-
没什么。 Hive 中的 LEFT JOIN 将产生预期的结果(您的最后一个数据集)。也许您的查询中有其他内容将其转换为 INNER JOIN。