首页 > 解决方案 > NOT IN 子查询与 hiveql 重新调整 NullPointerException null

问题描述

我正在尝试在配置单元中运行一个查询,该查询涉及在同一个表中内联 2 个数组并使用 NOT IN 运算符有效地获取差异

select c1 from t1 
lateral view inline(m1) m1
where m1.key = 'x'
AND t1.c1 NOT IN
(
select c1 from t1
lateral view inline(m2) m2
where m2.key = 'y'
);

上面的查询返回

FAILED: NullPointerException null

标签: hivehiveql

解决方案


首先过滤掉所有值为'y'的c1

With temp as
(select distinct c1 from t1
lateral view inline(m2) m2
where m2.key = 'y') 

select c1 from t1 
lateral view inline(m1) m1
where m1.key = 'x')
and c1 not in (select c1 from temp)

推荐阅读