[ 
https://issues.apache.org/jira/browse/FLINK-26362?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jark Wu reassigned FLINK-26362:
-------------------------------

    Assignee: luoyuxia

> "IndexOutOfBoundsException" when subquery select all field from using hive 
> dialect
> ----------------------------------------------------------------------------------
>
>                 Key: FLINK-26362
>                 URL: https://issues.apache.org/jira/browse/FLINK-26362
>             Project: Flink
>          Issue Type: Sub-task
>            Reporter: luoyuxia
>            Assignee: luoyuxia
>            Priority: Major
>              Labels: pull-request-available
>
> With hive dialect, can be reproduced using following code:
> {code:java}
>  tableEnv.executeSql("CREATE TABLE t1 (c1 INT, c2 CHAR(100))");
>  tableEnv.executeSql("CREATE TABLE t2 (c1 INT)");
> List<Row> results = CollectionUtil.iteratorToList(tableEnv.executeSql("SELECT 
> c1 FROM t1 WHERE c1 IN (SELECT c1 FROM t2)").
>                         collect());
> {code}
> Then it will throw IndexOutOfBoundsException: 0, the reason is from the 
> following comments:
> ??If it's a subquery and the project is identity, we skip creating this 
> project. This is to handle an issue with calcite SubQueryRemoveRule. The rule 
> checks col uniqueness by calling RelMetadataQuery::areColumnsUnique with an 
> empty col set, which always returns null for a project and thus introduces 
> unnecessary agg node.??
> So there could be no project node and only tablescan node in subquery. Then 
> when we try to do type conversion for the subquery, with the following code, 
> it'll throw exception when there's no project node.
> {code:java}
> if (queryRelNode instanceof Project) {
>   return replaceProjectForTypeConversion(
>                     rexBuilder,
>                     (Project) queryRelNode,
>                     targetCalcTypes,
>                     targetHiveTypes,
>                     funcConverter);
> } else {
>   RelNode newInput =
>                         addTypeConversions(
>                                 rexBuilder,
>                                 queryRelNode.getInput(0),
>                                 targetCalcTypes,
>                                 targetHiveTypes,
>                                 funcConverter);
>                 queryRelNode.replaceInput(0, newInput);
>                 return queryRelNode;
> }
> {code}



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

Reply via email to