Fix join condition lost after pull up sublink to join - #1961
Conversation
|
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 |
|
It looks like something wrong with subselect.out |
07fc7d0 to
0b53dfc
Compare
Thanks for catching this - the failure is in the expected output, not in the fix itself. This patch was cherry-picked from open-gpdb (a Greenplum 6 fork on a PG 9.4-era core), and I forgot to regenerate it against Cloudberry (PG 14.8). The two planners simply print a different plan for the same query. I updated it and now it is fine. |
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. The expected files were regenerated on Cloudberry: the plans the new test prints differ from the ones the upstream commit carried. (cherry picked from open-gpdb commit c06d16b)
0b53dfc to
6a601ed
Compare
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