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

HiveUnionPullUpConstantsRule produces an invalid plan when pulling up constants for nullable fields

    XMLWordPrintableJSON

Details

    Description

      The rule pulls up constants without checking/adjusting nullability to match that of the field type.

      Here is the stack-trace when a nullable type is involved:

      java.lang.AssertionError: Cannot add expression of different type to set:
      set type is RecordType(JavaType(class java.lang.Integer) f1, JavaType(int) NOT NULL f2) NOT NULL
      expression type is RecordType(JavaType(int) NOT NULL f1, JavaType(int) NOT NULL f2) NOT NULL
      set is rel#38:HiveUnion.(input#0=HepRelVertex#35,input#1=HepRelVertex#35,all=true)
      expression is HiveProject(f1=[1], f2=[$0])
        HiveUnion(all=[true])
          HiveProject(f2=[$1])
            HiveProject(f1=[$0], f2=[$1])
              HiveFilter(condition=[=($0, 1)])
                LogicalTableScan(table=[[]])
          HiveProject(f2=[$1])
            HiveProject(f1=[$0], f2=[$1])
              HiveFilter(condition=[=($0, 1)])
                LogicalTableScan(table=[[]])
      

      The solution is to check nullability and add a cast when the field is nullable, since the constant's type is not.

      Attachments

        Issue Links

          Activity

            People

              asolimando Alessandro Solimando
              asolimando Alessandro Solimando
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m