Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3609

Wrong query results in Hive due to wrong struct nullability

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Duplicate
    • Affects Version/s: 1.10.0, 1.16.0
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      student table:

      CREATE TABLE `student`(
        `id` int, 
        `info` struct<name:string,age:int>)
      ROW FORMAT SERDE 
        'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' 
      WITH SERDEPROPERTIES ( 
        'colelction.delim'=':', 
        'field.delim'=',', 
        'serialization.format'=',', 
        'serialization.null.format'='NULL')  
      

      the sql:

       

      select * from student where info is not null;
      

      result:

       

      1       {"name":"zhou","age":30}
      2       {"name":"yan","age":30}
      3       {"name":"chen","age":20}
      4       {"name":"li","age":80}
      NULL    NULL
      NULL    {"name":null,"age":null}
      

      cause:calcite Ineffective optimization

      HiveProject(id=[$0], info=[$1]) 
        HiveTableScan(table=[[default.student]], table:alias=[student])
      

       

      after fix RelRecordType isNullable,the plan is

      HiveProject(id=[$0], info=[$1])
        HiveFilter(condition=[IS NOT NULL($1)])
          HiveTableScan(table=[[default.student]], table:alias=[student])
      

      then the result is:

      1 {"name":"zhou","age":30} 
      2 {"name":"yan","age":30} 
      3 {"name":"chen","age":20} 
      4 {"name":"li","age":80}
      NULL    {"name":null,"age":null}
      
      

       

        Attachments

        1. calcite-3608.patch
          0.5 kB
          hezhang

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                heiheizhang hezhang
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: