Hive - 根据一列获取两个 Hive 表之间的差异

Hive - Get difference between two Hive tables based on one column

我有两个 Hive 表如下:

Table1:

c1 | c2 | c3
01 | june | true
02 | may | false


Table 2:

c1 | c4
01 | usa

我基本上想了解 Table A 和基于 C1 的 Table 之间的区别(wrt 设置操作上下文)。也就是说,我正在寻找包含 Table 1 但不在 Table 2 中的 c1 值的所有行。从上面的示例中,我需要从 Table 中获取第二行1 作为我的查询结果。

我尝试了以下 Hive 查询:

select c1 from table1 a left outer join table2 b

on a.c1 = b.c1 where b.c1 is null

我收到以下错误:

Error while compiling statement: FAILED: SemanticException Column c1 Found in more than One Tables/Subqueries

Table 1 和 Table 2 的第一列都命名为 c1。这是我无法改变的。

这里有我遗漏的东西吗?提前致谢!

这是在抱怨,因为您没有在 select c1 from 中为 c1 指定来源 table。您需要指定您想要 c1 来自哪个 table,因为它存在于两个 table 中。 select a.c1 from...应该给你你想要的。