[CALCITE-7687] RelMdSelectivity and RelMdDistinctRowCount for Aggregate can propagate a predicate with wrong references - #5145
Draft
etiennepelissier wants to merge 1 commit into
Conversation
…te can propagate a predicate with wrong references Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
etiennepelissier
force-pushed
the
calcite-7687-fix
branch
from
August 3, 2026 14:57
1b0f852 to
9994f65
Compare
|
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.



Jira Link
CALCITE-7687
Changes Proposed
Same defect as CALCITE-4414, in the
Aggregateoverloads. AnAggregate's output fieldiis inputfield
groupSet.nth(i), so a predicate expressed over the aggregate's output must be convertedbefore it is pushed to the input.
Adds
RelOptUtil.pushPastAggregate, alongside the existingpushPastProject/pushPastCalc, anduses it from
RelMdSelectivity.getSelectivity(Aggregate, ...)andRelMdDistinctRowCount.getDistinctRowCount(Aggregate, ...). The former also has its pushability testcorrected, from
getGroupSet()(input indices) torange(getGroupCount())(output indices).Three cases added to
RelMetadataTest; all three fail without this change. Mechanism, SQL repro anddownstream impact are in the Jira.