Description
OR clause is evaluated incorrectly in Hive query when the where the condition is evaluated as FALSE or TRUE. If we reverse the condition checks and it is evaluated as TRUE OR FALSE, it works fine.
Steps to repro :
CREATE TABLE `rtfnprepro1`( `id` int, `name` string, `zip` int, `city` string, `last` string, `ssn` int, `phone` int, `gender` string, `weight` int, `desc` string) PARTITIONED BY ( `country` string) ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.orc.OrcSerde' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'; insert into table rtfnprepro1 partition (country='INDIA') values (1, "abdcghjhkkjkjkkkgj",1,"PIShkjkkjhkkk","abc",1,2,"malhjkkjke",2,"helluuuuo"); select * from rtfnprepro1 where ((phone=1 and last='adc') OR (phone=2 and last!='adc')); select * from rtfnprepro1 where ( (phone=2 and last!='adc') OR (phone=1 and last='adc') );