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

Assertion error in FixNullabilityShuttle in RexUtil

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 1.5.0
    • 1.5.0
    • core
    • 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

              jcamacho Jesús Camacho Rodríguez
              jcamacho Jesús Camacho Rodríguez
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: