[GLUTEN-11550][UT] Fix PlanStability test suites for Velox backend#11799
Merged
baibaichen merged 1 commit intoapache:mainfrom Mar 20, 2026
Merged
[GLUTEN-11550][UT] Fix PlanStability test suites for Velox backend#11799baibaichen merged 1 commit intoapache:mainfrom
baibaichen merged 1 commit intoapache:mainfrom
Conversation
Fix BroadcastHashJoinExecTransformerBase.requiredChildDistribution to use bound+rewritten keys (matching Spark's BroadcastHashJoinExec), so that ValidateRequirements.validate(plan) passes when AQE is disabled. Add GlutenPlanStabilityTestTrait to override testQuery() - validates plans via ValidateRequirements instead of golden file comparison, since Gluten produces different physical plans with native Transformer operators. Apply fixes to all PlanStability test suites for both Spark 4.0 and 4.1: - GlutenTPCDSV1_4_PlanStabilitySuite - GlutenTPCDSV1_4_PlanStabilityWithStatsSuite - GlutenTPCDSV2_7_PlanStabilitySuite - GlutenTPCDSV2_7_PlanStabilityWithStatsSuite - GlutenTPCDSModifiedPlanStabilitySuite - GlutenTPCDSModifiedPlanStabilityWithStatsSuite - GlutenTPCHPlanStabilitySuite Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Run Gluten Clickhouse CI on x86 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the Spark 4.0 / 4.1 PlanStability test suites so they actually run with the Gluten plugin loaded on the Velox backend, and switches the verification from Spark-plan golden file comparison to validating Spark distribution/ordering requirements on Gluten-transformed physical plans.
Changes:
- Update Spark 4.0/4.1 PlanStability wrappers to use
GlutenSQLTestsBaseTraitand a newGlutenPlanStabilityTestTraitthat validates plans viaValidateRequirements. - Fix
BroadcastHashJoinExecTransformerBase.requiredChildDistributionto use bound + rewritten build keys so itsBroadcastDistributionmode matches theBroadcastExchangemode created by Spark’sEnsureRequirements.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenPlanStabilitySuite.scala |
Introduces GlutenPlanStabilityTestTrait and updates PlanStability suite wrappers to load the Gluten plugin and validate requirements instead of golden files. |
gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenPlanStabilitySuite.scala |
Same as Spark 4.1 version: ensures plugin loading and validates distribution/ordering requirements for Gluten plans. |
gluten-substrait/src/main/scala/org/apache/gluten/execution/JoinExecTransformer.scala |
Aligns BHJ requiredChildDistribution with Spark’s bound+rewritten key behavior to avoid broadcast mode mismatches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ulysses-you
approved these changes
Mar 20, 2026
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.
What changes were proposed in this pull request?
#11512 introduced PlanStability test suites for Spark 4.0 and 4.1 by extending Spark's original suites with
GlutenTestsCommonTrait. While the tests appeared to pass, they were not actually loading the Gluten plugin — they were effectively running vanilla Spark, which trivially passes golden file comparison against Spark's own approved plans.This PR fixes the suites properly by:
Switching from
GlutenTestsCommonTraittoGlutenSQLTestsBaseTrait, which configuresspark.plugins=org.apache.gluten.GlutenPluginand other Gluten-specific settings (off-heap memory, columnar shuffle, etc.), ensuring the Gluten native engine is actually loaded.Fixing
BroadcastHashJoinExecTransformerBase.requiredChildDistribution— it used rawbuildKeyExprs(AttributeReference) to constructHashedRelationBroadcastMode, while Spark'sEnsureRequirementscreatesBroadcastExchangewith bound+rewritten keys (BoundReference). This mode mismatch causedValidateRequirements.validate(plan)to fail for every query containing aBroadcastHashJoinwhen AQE is disabled. Fixed by aligning with Spark'sBroadcastHashJoinExecusingBindReferences.bindReferences(HashJoin.rewriteKeyExpr(keys), output).Adding
GlutenPlanStabilityTestTraitthat overridestestQuery()to validate plans viaValidateRequirementsinstead of golden file comparison, since Gluten intentionally produces different physical plans with native Transformer operators (e.g.,BroadcastHashJoinExecTransformer,ColumnarExchange).How was this patch tested?
All 7 test suites pass on both Spark 4.0 and 4.1 with Gluten plugin loaded:
GlutenTPCDSV1_4_PlanStabilitySuiteGlutenTPCDSV1_4_PlanStabilityWithStatsSuiteGlutenTPCDSV2_7_PlanStabilitySuiteGlutenTPCDSV2_7_PlanStabilityWithStatsSuiteGlutenTPCDSModifiedPlanStabilitySuiteGlutenTPCDSModifiedPlanStabilityWithStatsSuiteGlutenTPCHPlanStabilitySuiteTODO
requiredChildDistributionchange has no broader impact (only affects AQE-disabled path)Related issue: #11550