1

我的表格包括 3 个日期列, dateA , dateB 和 dateC 我需要什么:

JOIN ON dateA between dateB and dateC

JOIN 在 Teradata 中运行良好,但在 Hive 中运行时出现错误。

select *
from
table A
left join table B
on A.col1 = B.col1
and A.dateA between B.dateB and B.dateC

错误:

JOIN dateB 中遇到左右别名

我真的很感激这方面的一些帮助!

4

1 回答 1

0

原因是 Hive 不支持非 equi 连接。将 BETWEEN 连接条件移动到 WHERE

select *
from
table A
left join table B on A.col1 = B.col1
WHERE (A.dateA between B.dateB and B.dateC)
      OR B.col1 is NULL --allow not joined records from A (left join)
于 2022-02-22T15:51:14.817 回答