【问题标题】:hive search 2 columns are present in a single column in second table蜂巢搜索 2 列存在于第二个表的单个列中
【发布时间】:2016-11-08 17:58:47
【问题描述】:

在蜂巢中有 2 个表。表 2 是一个拥有数十亿条记录的主表。

表 1

name| id1 | id2
jac | 1   | 2
rac | 3   | 1

表 2

class | id
first | 1
second| 3   

如何在 hive 中编写有效的查询来搜索表 1 中的 id1 和 id2 都存在于表 2 中并隔离这些记录?

谢谢 毫秒

【问题讨论】:

    标签: hadoop hive


    【解决方案1】:

    可能JOIN是最好的方法:

    select t1.*
    from table1 t1 join
         table2 t2a
         on t1.id1 = t2a.id join
         table2 t2b
         on t1.id2 = t2b.id;
    

    在其他数据库中,EXISTSIN 可能更好,尤其是索引。我的猜测是简单的JOIN 在 Hive 中效果最好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 2016-05-29
      • 1970-01-01
      相关资源
      最近更新 更多