hive -e "set hive.execution.engine=mr;set hive.strict.checks.cartesian.product=false;
set hive.mapred.mode=nonstrict;
use db1;
select t1.col1, t1.col2
from tb1 t1
where t1.col_date='2020-08-15' and t1.col3='Y' and t1.col4='val4'
and t1.col1 not in
( select distinct t2.col1 from db2.tb2 t2
where t2.col_date='2020-08-15' and t2.col5='val5' and t2.col6='val6' and t2.col3='Y' and t2.col4='val4' ) "
或者,如果您的配置单元版本不支持not IN子查询,则可以使用LEFT JOIN+filter进行相同的查询
hive -e "set hive.execution.engine=mr;set hive.strict.checks.cartesian.product=false;
set hive.mapred.mode=nonstrict;
use db1;
select t1.col1, t1.col2
from tb1 t1
left join
( select distinct t2.col1 from db2.tb2 t2
where t2.col_date='2020-08-15'
and t2.col5='val5'
and t2.col6='val6'
and t2.col3='Y'
and t2.col4='val4'
) s on t1.col1 = s.col1
where t1.col_date='2020-08-15' and t1.col3='Y' and t1.col4='val4'
and s.col1 is null
"