“< =>”配置单元运算符的反运算不能正常工作?

3okqufwl  于 2021-06-26  发布在  Hive
关注(0)|答案(0)|浏览(235)

我必须在这里添加一些介绍,因为我的问题主要是代码;)
这是我的测试:

CREATE TABLE test (
  c1 string,
  c2 string
);

INSERT INTO test VALUES
  (NULL, NULL),
  ('A', NULL),
  ('A', 'B'),
  ('A', 'A')
;

SELECT *, (c1 <=> c2) as is_equal, (NOT (c1 <=> c2)) as is_not_equal
FROM test;

结果:

test.c1,test.c2,is_equal,is_not_equal
NULL,NULL,true,NULL
A,NULL,false,NULL
A,B,false,true
A,A,true,false

我更希望:

test.c1,test.c2,is_equal,is_not_equal
NULL,NULL,true,false
A,NULL,false,true
A,B,false,true
A,A,true,false

这是 hive 里的虫子吗?
编辑
此查询按预期工作:

SELECT *,
(c1 is null and c2 is null) or (c1 is not null and c2 is not null and c1 = c2) as is_equal,
(NOT ((c1 is null and c2 is null) or (c1 is not null and c2 is not null and c1 = c2))) as is_not_equal
FROM test;

编辑2
我们使用hive1.2.1(来自hdp2.6.2)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题