Skip to content

[CELEBORN-2575] Fix Spark SQL data size for columnar shuffle - #3992

Open
huangxiaopingRD wants to merge 1 commit into
apache:mainfrom
huangxiaopingRD:codex/fix-columnar-shuffle-data-size
Open

huangxiaopingRD wants to merge 1 commit into
apache:mainfrom
huangxiaopingRD:codex/fix-columnar-shuffle-data-size

Conversation

@huangxiaopingRD

@huangxiaopingRD huangxiaopingRD commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Count the input UnsafeRow sizes in the Spark SQL dataSize metric for the Spark 3, 3.5, and 4 columnar hash writers. Stop adding encoded batch lengths when full or remaining batches are flushed.

Why are the changes needed?

Spark's UnsafeRowSerializer counts the original row bytes, while the columnar writer currently counts the encoded columnar batch size. The same rows therefore produce different SQL statistics depending on the writer and encoding. For example, 100 integer rows of 16 bytes each produced a dataSize of 416 bytes instead of 1600 bytes in an isolated reproduction.

JIRA: https://issues.apache.org/jira/browse/CELEBORN-2575

Does this PR resolve a correctness bug?

  • Yes

This fixes SQL metric accounting. An effect on real AQE decisions has not been measured.

Does this PR introduce any user-facing change?

  • Yes

The SQL dataSize metric follows the same row-size convention as Spark's row serializer.

How was this patch tested?

  • A regression test failed before the fix and compares the columnar writer with Spark UnsafeRowSerializer after the fix. It covers two partitions, different row sizes, full and final partial batches, row-count and byte-size limits, and plain, codegen, and dictionary modes.
  • Spark 3.2 and 3.5: ColumnarHashBasedShuffleWriterSuiteJ passed with JDK 8 (16 tests per profile).
  • Spark 4.1: ColumnarHashBasedShuffleWriterSuiteJ (16 tests) passed with JDK 21 and -Dnet.bytebuddy.experimental=true. The JDK 21 build was run in a separate validation worktree with the existing TruthSelfEquals Error Prone check disabled to bypass an unrelated failure in ReadDataSuiteJ; that configuration change is not part of this PR.
  • Spark 3 and 3.5 Spotless checks and git diff --check passed. The changed Spark 4 Java files are byte-identical to the formatted Spark 3.5 files; direct Spark 4 Spotless on JDK 21 failed because the project's Google Java Format 1.7 is incompatible with JDK 21.

@huangxiaopingRD
huangxiaopingRD force-pushed the codex/fix-columnar-shuffle-data-size branch from 6093ba0 to 755761d Compare November 20, 2026 10:53
@github-actions github-actions Bot removed the correctness Correctness bugfix label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant