Fix join condition lost after pull up sublink to join - #1960
Conversation
After pulling up the sublink to join, the raw join condition may get lost in the rewritten query, potentially leading to incorrect results. Within the SubqueryToJoinWalker() function, we address this issue by adding an 'else' branch to prevent the loss of join clauses and keep them in their original positions. Cherry-picked from open-gpdb; the expected files were regenerated on Cloudberry, whose plans for the new test differ from GPDB's. (cherry picked from commit c06d16b)
c052b35 to
8230bf0
Compare
|
When a correlated aggregate subquery is pulled up into a join, A one-predicate set optimizer = off;
create table o (a int, d int); insert into o values (2, 1);
create table i1(a int); insert into i1 values (1);
create table i2(a int); insert into i2 values (1), (2);
select * from o where o.a > (select max(i2.a) from i1 join i2 on i2.a = i1.a where i1.a = o.d);
The fix adds an |
leborchuk
left a comment
There was a problem hiding this comment.
LGTM, let's place it without modification
Fix join condition lost after pull up sublink to join
After pulling up the sublink to join, the raw join condition may get
lost in the rewritten query, potentially leading to incorrect results.
Within the SubqueryToJoinWalker() function, we address this issue
by adding an 'else' branch to prevent the loss of join clauses and
keep them in their original positions.
(cherry picked from open-gpdb commit c06d16b)
Type of Change
Breaking Changes
Test Plan
make installcheckmake -C src/test installcheck-cbdb-parallelImpact
Performance:
User-facing changes:
Dependencies:
Checklist
Additional Context
CI Skip Instructions