You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "xiong duan (Jira)" <ji...@apache.org> on 2024/07/31 05:59:00 UTC
[jira] [Commented] (CALCITE-6506) Incorrect RelDataType generated for IN Subquery
[ https://issues.apache.org/jira/browse/CALCITE-6506?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17869813#comment-17869813 ]
xiong duan commented on CALCITE-6506:
-------------------------------------
+1. It has the same reason as CALCITE-4889. We use the left datatype instead of the right datatype.
> 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
> Priority: Major
>
> 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)