You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[GLUTEN-12538][VL] Fall back for unsupported Delta statistics plans - #13510
Prevent Delta 3.3/4 native writes from failing when their statistics plan cannot fully offload. Validate the entire statistics stage before constructing native tasks; otherwise log the rejection and reuse Delta's row-based statistics tracker through the existing columnar-to-row adapter.
Preserve native file writing and supported native statistics. The regression suite is shared with Delta 4 through the src-delta4/test symlink, and the statistics suites are selected in CI group 3 for Spark 3.5 (both Scala variants) and Spark 4.x. No native NTZ file-writing support, dependency changes beyond main, or known-failure changes are included.
How was this patch tested?
Before/after: On the original base (cce7716), the regression suite reproduced ClassCastException for projection/NTZ rejection and a column-count mismatch for partial aggregation offload. All four cases, including the native control, passed with the fix.
Historical runtime validation: 20/20 local tests passed at 8863b207 across Spark 4.1.1 / Delta 4.4.1 and Spark 3.5.5 / Delta 3.3.2. Actual CI reports at 8d14b6e6d then confirmed all four fallback-suite tests passed on Spark 3.5 and 4.1, plus the existing native NTZ test on Spark 3.5, with zero skips.
November 17 rebase:7f8189cda is based on main 2011f60b9, including [GLUTEN-12743][VL] Align Delta test parallelism and clean up aborted statistics #13578's native statistics cleanup. Resolved import conflicts in both trackers while preserving the upstream cleanup and this PR's eligibility/fallback logic. The separate CI-selector commit was dropped because those exact selectors are now in main.
Rebase validation: Scala formatting and license checks passed on the resolved source snapshot. Shared-source links and CI selection were checked; the existing regression tests and main's lifecycle tests are unchanged. No new local native runtime results are claimed.
Current-head CI (7f8189cda): fresh Velox x86, ARM, and Kafka workflows are queued in the fork. Earlier runtime/CI results above are historical, not validation of this composed head.
The historical DATE-to-NTZ ALTER setup was not rerun. The NTZ rejection regression exercises statistics directly, without bypassing the Delta 4 file-writer gate.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: GitHub Copilot (GPT-6 Astra, model ID: gpt-6-astra)
The reason will be displayed to describe this comment to others. Learn more.
🟢 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.
@zhztheplayer, @rui-mo, could you review #13510? It fixes the unchecked cast when Delta’s statistics plan cannot fully offload, including partially native plans. Supported statistics and file writing remain native, rejected statistics plans use the existing fallback tracker.
The regression tests fail before the fix and pass afterward.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The regression suite is compiled only for Delta 3.3, leaving the separately changed Delta 4 tracker and original Spark 4.x failure uncovered by the new CI selectors.
This suite is compiled only for Delta 3.3: Spark 4.x sets delta.binary.version=4, which selects src-delta4/test rather than this directory (pom.xml:1300,1857). The new Spark 4.x CI selectors therefore do not run these projection-rejection, partial-offload, or TIMESTAMP_NTZ regressions against the separately changed Delta 4 tracker. Add a Delta 4 variant or share the compatible tests across both source sets so CI covers the original Spark 4.x failure.
The Delta 4 coverage finding is a false positive. backends-velox/src-delta4/test/scala/org/apache/spark/sql/delta/GlutenDeltaStatsFallbackSuite.scala is already a tracked Git symlink (mode 120000) to the Delta 3.3 suite; it was included in the original patch.
The spark-test-spark41-group3-report artifact from CI run 42319505960 contains TEST-org.apache.spark.sql.delta.GlutenDeltaStatsFallbackSuite.xml with all four tests executed, zero failures/errors, and zero skips. That includes projection rejection, partial aggregation offload, NTZ rejection, and the supported-native control. No duplicate suite is needed.
Rebased onto main 3342737a4 at head aebaef0f7 to pick up the latest CI changes. Both patches are unchanged by range-diff, and the production/test files are byte-identical. Fresh CI is pending on the rebased head; the execution evidence above belongs to the previous head.
The reason will be displayed to describe this comment to others. Learn more.
You’re right to question whether we still need this. The original motivation was the NTZ statistics-support gap, which #12967 addressed. I haven’t identified another unsupported statistics pattern under default settings, so I’m not sure we should proceed with this PR in its current form.
The remaining reproductions are configuration-driven. For example, disabling native aggregation while keeping native writing enabled makes the statistics planner leave a Spark aggregate, but the tracker still assumes a fully native plan. That causes a column-count mismatch; disabling projection instead causes the unchecked ProjectExec cast to fail. Explicitly enabling NTZ validation also reproduces rejection in the direct statistics test.
This PR checks the complete stage—not just its root—and uses Spark statistics when it cannot fully offload, while retaining native file writing. It therefore handles those rejected plans safely rather than adding missing native support.
Before proceeding, could we clarify whether ordinary-query offload switches should also govern the writer’s internal statistics? If yes, this fixes crashes for that configuration. If not, statistics-specific planning rules would address those cases more directly, and we could defer the general fallback change. I’ve updated #12538 to distinguish the historical motivation from this remaining question.
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>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Maintainer confirmation is needed on whether general query-offload switches should govern internal Delta statistics, and queued current-head CI has not yet validated the native-task lifecycle integration.
Use GlutenExplainUtils.visitFallbackNodes for the existing warning in both tracker variants. Keep statistics offload eligibility and the fallback task selection unchanged.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Maintainer input is needed to resolve whether Delta’s internal statistics should follow ordinary-query offload switches or use statistics-specific planning rules.
No open issues 🎉
Review effort: Balanced
This branch has not been deployed
No deployments
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
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.
Prevent Delta 3.3/4 native writes from failing when their statistics plan cannot fully offload. Validate the entire statistics stage before constructing native tasks; otherwise log the rejection and reuse Delta's row-based statistics tracker through the existing columnar-to-row adapter.
Preserve native file writing and supported native statistics. The regression suite is shared with Delta 4 through the
src-delta4/testsymlink, and the statistics suites are selected in CI group 3 for Spark 3.5 (both Scala variants) and Spark 4.x. No native NTZ file-writing support, dependency changes beyond main, or known-failure changes are included.How was this patch tested?
cce7716), the regression suite reproducedClassCastExceptionfor projection/NTZ rejection and a column-count mismatch for partial aggregation offload. All four cases, including the native control, passed with the fix.8863b207across Spark 4.1.1 / Delta 4.4.1 and Spark 3.5.5 / Delta 3.3.2. Actual CI reports at8d14b6e6dthen confirmed all four fallback-suite tests passed on Spark 3.5 and 4.1, plus the existing native NTZ test on Spark 3.5, with zero skips.7f8189cdais based on main2011f60b9, including [GLUTEN-12743][VL] Align Delta test parallelism and clean up aborted statistics #13578's native statistics cleanup. Resolved import conflicts in both trackers while preserving the upstream cleanup and this PR's eligibility/fallback logic. The separate CI-selector commit was dropped because those exact selectors are now in main.7f8189cda): fresh Velox x86, ARM, and Kafka workflows are queued in the fork. Earlier runtime/CI results above are historical, not validation of this composed head.The historical DATE-to-NTZ ALTER setup was not rerun. The NTZ rejection regression exercises statistics directly, without bypassing the Delta 4 file-writer gate.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: GitHub Copilot (GPT-6 Astra, model ID: gpt-6-astra)