Hive 否定<=&燃气轮机&引用;蜂箱操作员工作不正常?
我必须在这里添加一些介绍,因为这么说我的问题主要是代码;) 这是我的测试:Hive 否定<=&燃气轮机&引用;蜂箱操作员工作不正常?,hive,operators,hiveql,Hive,Operators,Hiveql,我必须在这里添加一些介绍,因为这么说我的问题主要是代码;) 这是我的测试: 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_equ
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,false
A,NULL,false,true
A,B,false,true
A,A,true,false
这是蜂房里的虫子吗
编辑
此查询按预期工作:
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;
EDIT2
我们使用Hive 1.2.1(来自HDP2.6.2)我无法重现此问题并获得预期结果。您正在使用哪个版本的Hive?我们使用Hive 1.2.1(来自HDP2.6.2)
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;