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

Assertion error in FixNullabilityShuttle in RexUtil

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.5.0
    • Component/s: core
    • Labels:
      None

      Description

      In RexUtil.java, we can find the following class that is used to fix an expression to match changes in nullability of input fields, which is specially useful for inner/outer joins:

        public static class FixNullabilityShuttle extends RexShuttle {
          private final List<RelDataType> typeList;
          private final RexBuilder rexBuilder;
      
          public FixNullabilityShuttle(RexBuilder rexBuilder,
              List<RelDataType> typeList) {
            this.typeList = typeList;
            this.rexBuilder = rexBuilder;
          }
      
          @Override public RexNode visitInputRef(RexInputRef ref) {
            final RelDataType rightType = typeList.get(ref.getIndex());
            final RelDataType refType = ref.getType();
            if (refType == rightType) {
              return ref;
            }
            final RelDataType refType2 =
                rexBuilder.getTypeFactory().createTypeWithNullability(refType,
                    rightType.isNullable());
            if (refType2 == rightType) {
              return new RexInputRef(ref.getIndex(), refType2);
            }
            throw new AssertionError("mismatched type " + ref + " " + rightType);
          }
        }
      

      We are hitting the last assertion error in Hive. The reason seems to be that after adjusting the nullability, refType2 != rightType (which I think makes sense). In particular, it seems that the last if clause should be removed.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jcamachorodriguez Jesus Camacho Rodriguez
                Reporter:
                jcamachorodriguez Jesus Camacho Rodriguez
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: