dylanhz created FLINK-41386:
-------------------------------
Summary: Decorrelation fails when a correlated scalar subquery
projects a field of a ROW expression
Key: FLINK-41386
URL: https://issues.apache.org/jira/browse/FLINK-41386
Project: Flink
Issue Type: Bug
Components: Table SQL / Planner
Reporter: dylanhz
h3. Reproducer
{code:sql}
SELECT (SELECT CAST(ROW(t.x) AS ROW(f INTEGER)).f)
FROM (VALUES (1)) AS t(x);
{code}
h3. Expected result
The query returns one row containing {{1}}.
h3. Actual result
On Apache Flink 2.4-SNAPSHOT, planning fails in both batch and streaming modes.
{noformat}
org.apache.flink.table.api.TableException: unexpected correlate variable $cor1
in the plan
{noformat}
Replacing the inner projection with {{t.x}} succeeds in both modes. In the
failing case, {{RemoveCorrelationRexShuttle.visitFieldAccess}} returns the
outer field access unchanged, leaving the correlated reference inside
{{ROW(t.x)}} after decorrelation.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)