Zhen Chen created CALCITE-7395:
----------------------------------
Summary: ProjectMergeRule incorrectly merges PROJECTs with
correlation variables
Key: CALCITE-7395
URL: https://issues.apache.org/jira/browse/CALCITE-7395
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.41.0
Reporter: Zhen Chen
The ProjectMergeRule cannot merge projects with correlation variables.
This is SQL:
{code:java}
SELECT ARRAY(SELECT y + 1 FROM UNNEST(s.x) y)
FROM (SELECT ARRAY[1,2,3] as x) s {code}
The correct plan is following after processing with ProjectMergeRule:
{code:java}
LogicalProject(variablesSet=[[$cor0]], EXPR$0=[ARRAY({
LogicalProject(EXPR$0=[+($0, 1)])
Uncollect
LogicalProject(X=[$cor0.X])
LogicalValues(tuples=[[{ 0 }]])
})])
LogicalProject(X=[ARRAY(1, 2, 3)])
LogicalValues(tuples=[[{ 0 }]]) {code}
But current plan is:
{code:java}
LogicalProject(EXPR$0=[ARRAY({
LogicalProject(EXPR$0=[+($0, 1)])
Uncollect
LogicalProject(X=[$cor0.X])
LogicalValues(tuples=[[{ 0 }]])
})])
LogicalValues(tuples=[[{ 0 }]]) {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)