Repository navigation
[GLUTEN-12538][VL] Fall back for unsupported Delta statistics plans - #13510
Draft
felipepessoto wants to merge 1 commit into
Draft
felipepessoto wants to merge 1 commit into
felipepessoto wants to merge 1 commit into
Conversation
Validate the entire local statistics plan before creating the native task. Reuse Delta statistics through the existing columnar-to-row fallback when any required operator remains in Spark, preserving native file writing and file statistics. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Run Gluten Clickhouse CI on x86 |
felipepessoto
marked this pull request as draft
October 31, 2026 23:10
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the statistics-fallback change.
No open issues 🎉
What changed in this PR
Addresses #12538 by falling back to Delta’s row-based statistics tracker when the complete statistics plan cannot run natively. This preserves native file writing and supported native statistics without changing Delta 4’s TIMESTAMP_NTZ writer restriction.
Changes:
- Validate the full statistics stage before constructing native tasks in both Delta variants, and log fallback reasons.
- Add regression coverage for supported and rejected statistics plans, plus fallback during partitioned file rotation and batch splitting.
- Update the writer documentation to describe statistics fallback.
| File | Description |
|---|---|
gluten-ut/spark35/src-delta/test/scala/org/apache/spark/sql/execution/datasources/GlutenDeltaNativePartitionWriteSuite.scala |
Adds partitioned-write cases with statistics offload disabled. |
docs/backends/velox/get-started/VeloxDelta.md |
Documents statistics fallback and removes the resolved crash limitation. |
backends-velox/src-delta4/main/scala/org/apache/spark/sql/delta/stats/GlutenDeltaJobStatsTracker.scala |
Selects native or fallback statistics after full-stage validation for Delta 4. |
backends-velox/src-delta33/test/scala/org/apache/spark/sql/delta/GlutenDeltaStatsFallbackSuite.scala |
Checks native writer provenance, statistics values, and rejected-plan fallback. |
backends-velox/src-delta33/main/scala/org/apache/spark/sql/delta/stats/GlutenDeltaJobStatsTracker.scala |
Applies the same statistics-stage validation and fallback for Delta 3.3. |
Review effort: Balanced
This was referenced Oct 31, 2026
This branch has not been deployed
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 are proposed in this pull request?
Fixes #12538.
The Delta statistics tracker assumes that its local statistics plan always becomes a native whole stage. A rejected projection instead leaves a Spark
ProjectExec, causing the unchecked cast to fail. Checking only the root is insufficient: disabling aggregation offload leaves a native projection above a Spark aggregate, and the local evaluator then receives raw input batches where it expects aggregate output.For both Delta 3.3 and Delta 4, select the statistics implementation before constructing the native task. Use native aggregation only when the complete stage is transformable, with the expected statistics-input adapters. Otherwise log the validation reasons and reuse
GlutenDeltaJobStatsFallbackTracker, which converts the incoming batches to rows for Delta's original tracker. Native file writing and supported native statistics remain enabled.Add a shared backend regression suite covering supported native statistics, rejected projections, partially offloaded aggregation, and rejected NTZ statistics. Extend the
gluten-utpartitioned-write matrix to cover statistics fallback across file rotation and batch splitting, and update the writer documentation. Tests check actual writer provenance, file contents, row/null counts, nested min/max, all-null columns, and native statistics execution rather than only absence of exceptions.The existing Delta 4 NTZ file-writer gate is unchanged; this does not enable native NTZ file writing. No dependency pins, DATE-reader patches, CI workflows, or upstream-test baseline entries are changed.
How was this patch tested?
Built fresh native libraries from main commit
cce7716962d3152b46fc22882bed4a3887a792efand its unchanged IBM Velox pinbd5d1828bc100d7c3d83c0fb77ed15a1c2e8b8c4, before building the JVM modules. Native build and runtime used the sameapache/gluten:centos-9-jdk17builder filesystem, GCC toolset 13 and JDK 17.0.20. No historical or reader-patched native binaries were reused.Red/green: with only the new tests overlaid on unmodified main,
GlutenDeltaStatsFallbackSuiteran four tests on Spark 4.1.1 / Delta 4.4.1: the supported-native control passed, while the other three failed. Projection and NTZ rejection reproducedProjectExec cannot be cast to WholeStageTransformer; aggregation-only rejection reproduced(3 vs. 10) Value stream batch has fewer columns than the declared output type. All four pass with this fix.GlutenDeltaStatsFallbackSuiteGlutenDeltaNativePartitionWriteSuiteVeloxDelta4WriteSuite:TIMESTAMP_NTZ falls back, at any depthGlutenDeltaStatsFallbackSuiteGlutenDeltaStatsSuitenative NTZ statistics testGlutenDeltaNativePartitionWriteSuiteThe JVM modules were built with
./build/mvn, using the corresponding Spark/Scala profiles plusbackends-velox,delta,spark-ut,fast-build; Spark 4.1 also usedjava-17and-Dmaven.compiler.release=17. A clean reactor build was used when switching to Spark 3.5. Actual Spark/Delta/Scala runtime versions were checked in the JUnit classpaths. The tested Linux source tree matches the committed tree (21bfaef702a524bca532c37f969a6e922e86ddc0).Also passed
./dev/format-scala-code.sh, the license-header check (check.py header main --fix), andgit diff --cached --check.Local validation did not rerun the historical Spark 4.1.0 / Delta 4.2.0 DATE-to-NTZ ALTER setup or the entire upstream/Spark-version matrix. The NTZ fallback regression exercises the statistics stream without bypassing Delta 4's file-writer gate.
Completed CI for head
8863b207d27a1128065429edbbef4bed7eea30a6: Velox x86 and ARM, Velox Kafka, ClickHouse, Scala formatting and license checks passed. The Delta 4.4.1 workflow completed all eight shards: 22,100 passed, 471 expected baseline failures, 5,160 skipped, zero regressions, and 14 now-passing baseline entries. The workflow is red only because strictfail-on-fixedenforcement requires removing those 14 stale nested-map MERGE entries; their separate cleanup is already in #13508, and is not duplicated here. These counts were independently reproduced from all downloaded JUnit XML using the exact CI comparator and baseline/quarantine blobs. CI checkoutd30bfe2ad14752b499fa6af27eb01b77e922b0a7has parentscce7716and this PR head. No reader override was used, and this result is not a claim that the DATE-widening baseline failures were fixed.Was this patch authored or co-authored using generative AI tooling?
Generated-by: GitHub Copilot (GPT-6 Astra, model ID: gpt-6-astra)