Preserve aggregate results for outer joins without criteria - #30989
Open
bvolpato wants to merge 1 commit into
Open
Preserve aggregate results for outer joins without criteria#30989bvolpato wants to merge 1 commit into
bvolpato wants to merge 1 commit into
Conversation
Skip aggregation pushdown when the join has no equijoin criteria. Otherwise the pushed global aggregation produces a row for empty input, changing the result over the null-extended outer row.
findepi
reviewed
Sep 4, 2026
| } | ||
|
|
||
| @Test | ||
| public void testCountOverEmptyLeftJoin() |
Member
There was a problem hiding this comment.
"empty left join" is kinda misleading. the join result is not empty. it's the right side of the left join who's empty.
let's call it testCountOverOuterJoinWithEmptyInnerSide and let's merge the RIGHT JOIN test case (testCountOverEmptyRightJoin) with this test mehod
findepi
reviewed
Sep 4, 2026
| } | ||
|
|
||
| @Test | ||
| public void testCountOverEmptyLeftJoin() |
Member
There was a problem hiding this comment.
Suggested change
| public void testCountOverEmptyLeftJoin() | |
| public void testCountOverOuterJoinWithEmptyInnerSide() |
Comment on lines
+389
to
+393
| } | ||
|
|
||
| @Test | ||
| public void testCountOverEmptyRightJoin() | ||
| { |
Member
There was a problem hiding this comment.
Suggested change
| } | |
| @Test | |
| public void testCountOverEmptyRightJoin() | |
| { |
| } | ||
|
|
||
| @Test | ||
| public void testGroupedCountOverEmptyOuterJoin() |
findepi
marked this pull request as ready for review
September 4, 2026 08:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Preserve aggregate results when an outer join has no equijoin criteria. Pushing aggregation below such a join creates a global aggregation, which emits a row even when its input is empty. That changes
count(*)over the preserved outer row from1to0.This returns
0before the fix and1afterward. The rule now skips joins without equijoin criteria. Regressions cover LEFT and RIGHT joins and grouped counts.Additional context and related issues
Existing equijoin aggregation pushdown remains covered by the rule tests. The five new regressions failed before the production change. Afterward, all 25 tests in
TestJoinandTestPushAggregationThroughOuterJoinpassed. Mavenvalidate, including Checkstyle and Airstyle, passed forcore/trino-main../mvnw -pl core/trino-main -Dtest=TestJoin,TestPushAggregationThroughOuterJoin -Dair.check.skip-all=true test ./mvnw -pl core/trino-main validateDownsides
Aggregations over outer joins without equijoin criteria can process more intermediate rows because this pushdown is no longer applied.
Release notes
(x) Release notes are required, with the following suggested text: