branch-4.1: [refactor](fe) Create PreAggInfoContext top-down from aggregate instead of bottom-up from scan in SetPreAggStatus #65237#65372
Open
github-actions[bot] wants to merge 1 commit into
Conversation
…ad of bottom-up from scan in SetPreAggStatus (#65237) related pr: #48502 Problem Summary: The `SetPreAggStatus` rule previously created `PreAggInfoContext` at `LogicalOlapScan` nodes (bottom-up): the first encountered AGG_KEYS scan pushed a new context onto the stack, subsequent scans and intermediate nodes (filter/join/project) filled in information, and `LogicalAggregate` popped and consumed the context. This bottom-up approach had two issues: 1. **Nested aggregate information loss**: When a query contains nested aggregates (e.g., an outer aggregate over an inner aggregate), the inner aggregate's `visitLogicalAggregate` would pop the only context on the stack, leaving the outer aggregate with no context for scans directly under it. 2. **Unclear context ownership**: Context lifecycle was split across scan (creation) and aggregate (consumption), making the ownership boundary implicit and fragile — intermediate plan nodes that call `context.clear()` via the base `visit()` method could inadvertently destroy the context. This PR refactors the context propagation to a **top-down** model: - `visitLogicalAggregate` now creates a fresh `PreAggInfoContext`, pushes it onto the stack, visits children, then pops and stores it. - `visitLogicalOlapScan` only fills relation IDs into an existing context; it no longer creates contexts. - The `retainAll` filtering is no longer needed since each aggregate creates its own isolated context with only the scan IDs from its subtree. - Nested aggregates each get their own independent context, correctly isolating preagg information per aggregate level.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
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.
Cherry-picked from #65237