Skip to content

[VL] Fix SPARK-53322 in GlutenKeyGroupedPartitioningSuite for Spark 4.1#12469

Open
zml1206 wants to merge 1 commit into
apache:mainfrom
zml1206:SPARK-53322-ut
Open

[VL] Fix SPARK-53322 in GlutenKeyGroupedPartitioningSuite for Spark 4.1#12469
zml1206 wants to merge 1 commit into
apache:mainfrom
zml1206:SPARK-53322-ut

Conversation

@zml1206

@zml1206 zml1206 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR fixes SPARK-53322 coverage in GlutenKeyGroupedPartitioningSuite for Spark 4.1 with Velox backend.

Spark 4.1 adds several SPARK-53322 tests to verify that checkpointed scans are not incorrectly reused for Storage Partitioned Join planning. The upstream Spark tests assert shuffle counts using vanilla Spark ShuffleExchangeExec, but Gluten may use ColumnarShuffleExchangeExec, and KeyGroupedPartitioning shuffle may also fall back to vanilla Spark shuffle after GLUTEN-10992.

This PR keeps the upstream SPARK-53322 tests excluded in Velox test settings, and adds Gluten-aware versions in GlutenKeyGroupedPartitioningSuite.

The new tests verify:

  • checkpointed scans do not introduce extra shuffles for aggregate queries
  • checkpointed scans are not incorrectly used for SPJ
  • checkpointed scans cannot force other children to satisfy SPJ
  • checkpointed scans can still be shuffled by other children when needed

For the mixed shuffle case, the test separately counts:

  • ColumnarShuffleExchangeExec for Gluten columnar shuffle
  • ShuffleExchangeExec for vanilla fallback shuffle

This is needed because KeyGroupedPartitioning shuffle is not supported by Gluten native shuffle and should remain as vanilla Spark shuffle.

Copilot AI review requested due to automatic review settings July 7, 2026 10:23
@github-actions github-actions Bot added the CORE works for Gluten Core label Jul 7, 2026

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.

Pull request overview

Adds Spark 4.1-specific regression coverage for SPARK-53322 within Gluten’s KeyGroupedPartitioning test suite, focusing on how checkpointed scans interact with shuffle planning (especially around SMJ/SPJ scenarios) under the Velox backend test environment.

Changes:

  • Added multiple SPARK-53322 regression tests covering aggregates and partitioned-join scenarios when inputs are checkpointed.
  • Introduced a helper to collect vanilla ShuffleExchangeExec nodes from an executed plan (in addition to existing columnar-shuffle collectors).
  • Updated Spark 4.1 Velox test settings to exclude tests by the SPARK-53322 prefix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
gluten-ut/spark41/src/test/scala/org/apache/spark/sql/connector/GlutenKeyGroupedPartitioningSuite.scala Adds SPARK-53322 regression tests and a helper for collecting vanilla shuffles to validate exchange behavior with checkpointed scans.
gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala Adjusts Velox Spark 4.1 suite exclusions to include the SPARK-53322 prefix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.excludeByPrefix("SPARK-48012")
.excludeByPrefix("SPARK-44647")
.excludeByPrefix("SPARK-41471")
.excludeByPrefix("SPARK-53322")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The newly added testGluten uses "Gluten - " as a prefix.

Comment on lines +1883 to +1886
withTempDir {
dir =>
spark.sparkContext.setCheckpointDir(dir.getPath)
val itemsPartitions = Array(identity("id"))
Comment on lines +1899 to +1902
val shuffles = collectAllShuffles(df.queryExecution.executedPlan)
assert(
shuffles.isEmpty,
"should not contain shuffle when not grouping by partition values")
checkAnswer(df, Seq(Row(1, "aa", 41.0, 40.0), Row(3, "cc", 15.5, 25.5)))

// One shuffle for sort and two shuffles for join are expected.
assert(collectAllShuffles(df.queryExecution.executedPlan).length === 3)
checkAnswer(df, Seq(Row(1, "aa", 41.0, 40.0), Row(3, "cc", 15.5, 25.5)))

// One shuffle for sort and two shuffles for join are expected.
assert(collectAllShuffles(df.queryExecution.executedPlan).length === 3)
@zml1206 zml1206 requested review from philo-he and zhouyuan July 7, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants