← Back to Pull requests

fix: declare required child distribution on aggregate, window and join operators #7231

Closed
unknown closed this pull request without merging on Oct 30, 2026 04:34 UTC
View on GitHub
unknown unknown commented on Oct 26, 2026 12:16 UTC
Author

Which issue does this PR close?

Closes #7208.

Rationale for this change

With AQE on, REBALANCE(k) followed by GROUP BY k returns duplicate groups when the data is skewed, and a PARTITION BY k window restarts row_number() inside a key. Spark's OptimizeSkewInRebalancePartitions splits the skewed shuffle partition. In plain Spark that is safe, because ValidateRequirements rejects the split when an operator above needs ClusteredDistribution(k). Comet's aggregate, window and join operators declared no requiredChildDistribution, so the check always passed and the native operators ran over the pieces of a key separately.

What changes are included in this PR?

A new trait, CometDelegatesRequiredChildDistribution, returns originalPlan.requiredChildDistribution. It is mixed into CometBaseAggregateExec, CometWindowExec, CometWindowGroupLimitExec, CometHashJoinExec and CometSortMergeJoinExec, so each declares the same requirement as the Spark operator it replaces. requiredChildOrdering and the broadcast hash join are unchanged.

How are these changes tested?

New test in CometExecSuite, AQE does not split a skewed rebalance partition under operators that need clustering. It uses the data from the issue and checks the GROUP BY query (also with a project and filter below it), the row_number() window query, a window group limit (rn <= 2), and a self-join with sort-merge join on and off. Each query is compared with Spark, and the plan is asserted to have no skewed AQEShuffleReadExec.

The test fails without the operator changes and passes with them. CometExecSuite, CometWindowExecSuite, CometJoinSuite and CometAggregateSuite pass on the default profile (Spark 4.1): 535 tests, 0 failures.

Diff: 221 lines (+165 / -56) across 2 files Reviewer: rich7420 Review duration: 5298m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 221 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.323
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7231"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.8% (MEDIUM) · Higher = larger blast radius
36.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.5% · Safe to merge
14.5%