【问题标题】:Hive - Get difference between two Hive tables based on one columnHive - 基于一列获取两个 Hive 表之间的差异
【发布时间】:2015-09-12 12:28:21
【问题描述】:

我有两个 Hive 表如下:

Table1:

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


Table 2:

c1 | c4
01 | usa

我基本上想了解表 A 和基于 C1 的表之间的区别(wrt 设置操作上下文)。也就是说,我正在查找包含表 1 中但不在表 2 中的 c1 值的所有行。从上面的示例中,我需要从表 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

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

这里有什么我遗漏的吗?提前致谢!

【问题讨论】:

    标签: hive outer-join hiveql


    【解决方案1】:

    因为您没有在select c1 from 中指定c1 的源表,所以它在抱怨。您需要指定要从哪个表中获取c1,因为它存在于两个表中。 select a.c1 from... 应该给你你想要的。

    【讨论】:

    • 啊!现在这是一个愚蠢的问题!不过,谢谢你耐心的回答。欣赏!
    猜你喜欢
    • 2011-03-28
    • 1970-01-01
    • 2021-07-04
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 2019-05-12
    相关资源
    最近更新 更多