Hive QL Except clause

前端 未结 2 1185
旧巷少年郎
旧巷少年郎 2021-01-02 01:33

How do I do an EXCEPT clause (like SQL) in Hive QL

I have 2 tables, and each table is a column of unique ids.

I want to find the list of ids tha

相关标签:
2条回答
  • 2021-01-02 01:53

    I don't think there's any built-in way to do this but a LEFT OUTER JOIN should do the trick.

    This selects all Ids from table1 that do not exist in table2:

    SELECT t1.id FROM table1 t1 LEFT OUTER JOIN table2 t2 ON (t1.id=t2.id) WHERE t2.id IS NULL;
    
    0 讨论(0)
  • 2021-01-02 02:11

    We can use NOT EXISTS clause in Hive as MINUS equivalent.

    SELECT t1.id FROM t1 WHERE NOT EXISTS (SELECT 1 from t2 WHERE t2.id = t1.id);
    
    0 讨论(0)
提交回复
热议问题