[
https://issues.apache.org/jira/browse/FLINK-40694?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated FLINK-40694:
-----------------------------------
Labels: pull-request-available (was: )
> INSERT INTO with a column list fails over a process table function with a
> set-semantic table argument
> -----------------------------------------------------------------------------------------------------
>
> Key: FLINK-40694
> URL: https://issues.apache.org/jira/browse/FLINK-40694
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Affects Versions: 2.3.0, 2.4.0
> Reporter: Martijn Visser
> Priority: Major
> Labels: pull-request-available
>
> An INSERT INTO that has an explicit target column list, or static partitions,
> fails during
> SQL-to-Rel conversion when its source query reads from a process table
> function with a
> set-semantic table argument.
> INSERT INTO snk (id, payload)
> SELECT id, payload FROM f(r => TABLE src PARTITION BY id, i => 1);
> java.lang.IllegalStateException: must call validate first
> at
> org.apache.calcite.sql.validate.IdentifierNamespace.resolve(IdentifierNamespace.java:255)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:3112)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.substituteSubQueryOfSetSemanticsInputTable(SqlToRelConverter.java:1545)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.convertCollectionTable(SqlToRelConverter.java:3170)
> {{PreValidateReWriter}} only runs when the statement has a target column list
> or static
> partitions, and it validates the source query once so that it can rewrite it.
> {{FlinkPlannerImpl.validateRichSqlInsert}} then validates the same node a
> second time with the
> same validator, which leaves the namespace of the set-semantic table argument
> unvalidated.
> Dropping the column list avoids the rewrite and the statement works.
> On 2.0 up to 2.3 the same guard in Calcite is an assert, so with assertions
> disabled the failure
> is a NullPointerException without a message instead.
> Same cause as FLINK-40039, which moved CTAS and RTAS off that rewrite.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)