Skip to content

[VL] Eager aggregation: Refactor option partialMerge.mode - #13328

Merged
zhztheplayer merged 7 commits into
apache:mainfrom
zhztheplayer:wip-refactor-eager
Oct 16, 2026
Merged

zhztheplayer merged 7 commits into
apache:mainfrom
zhztheplayer:wip-refactor-eager

Conversation

@zhztheplayer

@zhztheplayer zhztheplayer commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Separate aggregate pushdown placement from physical staging:

  • partialMerge.enabled: retain local merges between pushed joins.
  • twoStage.mode=NONE|FINAL: optionally add a mapper-side merge before the final shuffle.

This avoids a separate logical merge above the topmost join and leaves BHJ inputs unchanged.

Breaking change: replaces partialMerge.mode. Old NONE → false/NONE, TOP → false/FINAL, ALL → true/FINAL.

Updates configuration docs and separates logical-pushdown and physical-staging tests.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions github-actions Bot added CORE works for Gluten Core VELOX DOCS labels Oct 15, 2026
@zhztheplayer
zhztheplayer marked this pull request as ready for review October 16, 2026 12:32
Copilot AI balanced review requested due to automatic review settings October 16, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

TOP staging retains reducer references that are unavailable after mapper aggregation.

3 open findings
What changed in this PR

Separates eager aggregation’s logical merge placement from physical staging.

Changes:

  • Replaces partialMerge.mode with partialMerge.enabled and twoStage.mode.
  • Adds optional mapper-side merging before final aggregation.
  • Updates configuration documentation and test variants.
File Description
gluten-substrait/​src/​test/​scala/​org/​apache/​gluten/​execution/​PushAggregateThroughJoinSuite.scala Updates logical merge-count expectations.
gluten-substrait/​src/​main/​scala/​org/​apache/​gluten/​extension/​joinagg/​PushAggregateThroughJoin.scala Retains logical merges only between joins.
gluten-substrait/​src/​main/​scala/​org/​apache/​gluten/​extension/​joinagg/​ImplementJoinAggregate.scala Implements optional two-stage final aggregation.
gluten-substrait/​src/​main/​scala/​org/​apache/​gluten/​config/​GlutenConfig.scala Defines replacement configuration options.
docs/​Configuration.md Documents the new options.
backends-velox/​src/​test/​scala/​org/​apache/​gluten/​execution/​StarSchemaJoinAggregateSuite.scala Reorganizes configuration-specific test suites.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

distribution)
} else {
planFinalOutput(grouping, resultExpressions, preparedChild, rewrittenAggExprs)
buildFinalAggregate(grouping, resultExpressions, stageChild, stageExpressions, distribution)
Comment on lines +182 to +183
val stageChild = if (stage == AggregationStage.TWO_STAGE) {
buildMapperAggregate(grouping, preparedChild, rewrittenAggExprs)
Copilot AI balanced review requested due to automatic review settings October 16, 2026 13:37
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two-stage reducers mishandle computed grouping keys and input-buffer offsets for grouped imperative aggregates.

4 open findings
1 resolved since last review

🧠 Review effort: Balanced

ae =>
val mode = ae.mode match {
case Partial => PartialMerge
case Complete => Final
distribution)
} else {
planFinalOutput(grouping, resultExpressions, preparedChild, rewrittenAggExprs)
buildFinalAggregate(grouping, resultExpressions, stageChild, stageExpressions, distribution)
Copilot AI balanced review requested due to automatic review settings October 16, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Previously reported two-stage reducer correctness issues remain unresolved in the supplied changes.

4 open findings

🧠 Review effort: Balanced

@zhztheplayer
zhztheplayer merged commit 1cf2c0d into apache:main Oct 16, 2026
77 of 79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core DOCS VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants