Brandon Chong created CALCITE-6506:
--------------------------------------

             Summary: Incorrect RelDataType generated for IN Subquery
                 Key: CALCITE-6506
                 URL: https://issues.apache.org/jira/browse/CALCITE-6506
             Project: Calcite
          Issue Type: Bug
            Reporter: Brandon Chong


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).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to