Hive 如何从配置单元中的两个表中获取不匹配的记录?

Hive 如何从配置单元中的两个表中获取不匹配的记录?,hive,hiveql,Hive,Hiveql,下面有两个数据表,我只需要使用hive获取不匹配的数据记录 表1: hive> select * from dept; OK 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 表2: hive> select * from dept_text; OK 10 ACCOUNTING

下面有两个数据表,我只需要使用hive获取不匹配的数据记录

表1:

hive> select * from dept;
OK
10      ACCOUNTING      NEW YORK
20      RESEARCH        DALLAS
30      SALES   CHICAGO
40      OPERATIONS      BOSTON
表2:

hive> select * from dept_text;
OK
10      ACCOUNTING      NEW YORK
20      RESEARCH        DALLAS
30      SALES   CHICAGO
40      OPERATIONS      BOSTON
50      Software        Bangalore
60      Housewife       yellandu
输出:我需要得到如下输出。有人能帮我吗

50      Software        Bangalore
60      Housewife       yellandu

dept\u text表上使用
left join
,然后只过滤dept表中的null id

select dt.* from dept_text dt 
    left join 
dept d 
  on d.id=dt.id 
where d.id is null;

示例:

desc dept;
--id                    int
--desc                  string
--city                  string

select * from dept;
--OK
--dept.id   dept.desc   dept.city
--10    ACCOUNTING  NEW YORK
--20    RESEARCH    DALLAS
--30    SALES   CHICAGO
--40    OPERATIONS  BOSTON

--if you want to join on desc column

select dt.* from dept_text dt 
left join 
dept d 
on d.desc=dt.desc 
where d.id is null;

--or if you want to join on id column

select dt.* from dept_text dt 
left join 
dept d 
on d.id=dt.id 
where d.id is null;