Search code examples
hadoophivedelete-row

compare two tables and delete rows from one table if there are similar coumn values in two tables hive


Table description are in the link

Table 1 and Table 2 has rows with A and D .I need these two removed from Table 2 .

Please check the link below for descriptive detail . Thank you .


Solution

  • You may do an INSERT OVERWRITE using a LEFT JOIN select query.

    INSERT overwrite TABLE table2
    SELECT t2.* 
      from table2 t2
           LEFT JOIN table1 t1
            on (t1.x = t2.p) --use appropriate common column name 
    WHERE t1.x is NULL; --where there's no common element in t2