Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-19761

Incorrect evaluation of OR condition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Invalid
    • 1.2.1
    • None
    • CLI, Parser
    • None

    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') );
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rtrivedi12 Riju Trivedi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: