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

Type inference for IN list is incorrect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.38.0
    • None

    Description

      If a user writes a query like:
       
       select * from cp."iceberg/orders/orders.parquet" where o_orderkey IN (1, 2, 3)
      It get's rewritten to use a LogicalValues with RelDataType nullable INTEGER row type. The problem is that it's actually NOT NULL.

      You can see the issue in SqlToRelConverter:
       
       {{final RelDataType targetRowType = SqlTypeUtil.promoteToRowType(typeFactory,
      validator.getValidatedNodeType(leftKeyNode), null);
      final boolean notIn = call.getOperator().kind == SqlKind.NOT_IN;
      converted =
      convertExists(query, RelOptUtil.SubQueryType.IN, subQuery.logic,
      notIn, targetRowType);}}
      Note that it's using the type of the leftKeyNode and not right key node.

      For example: A IN (B, C, D) ... it's using typeof(A) instead of typeof(B, C, D).

      Attachments

        Issue Links

          Activity

            People

              nobigo xiong duan
              brandon.chong Brandon Chong
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: