Uh oh!
There was an error while loading. Please reload this page.
[GLUTEN-12538][VL] Fall back to row-based Delta stats when the stats plan cannot be offloaded - #12539
[GLUTEN-12538][VL] Fall back to row-based Delta stats when the stats plan cannot be offloaded#12539felipepessoto wants to merge 1 commit into
Conversation
d3e2609 to
d6f60b9Compared6f60b9 to
5f1d46eCompareSmallfu666
commented
Jul 28, 2026
I independently reproduced this on Spark 4.0 and validated the row-based fallback. One question: could |
felipepessoto
commented
Jul 28, 2026
I'll wait until #12388 is merged before publishing this and other PRs depending on it for validation, to avoid confusion. |
5f1d46e to
7d30ccbCompare…plan cannot be offloaded GlutenDeltaJobStatsTracker collects Delta write statistics by building a local Velox aggregation plan and assuming it is always offloaded to a WholeStageTransformer. When the stats plan references a type/expression Velox cannot offload (for example an aggregate over TIMESTAMP_NTZ), the offload rules reject it and leave a vanilla ProjectExec, so the unconditional cast threw `ClassCastException: ProjectExec cannot be cast to WholeStageTransformer` and failed the whole write. The decision is now made on the executor in newTaskInstance(), where the native plan is actually built. tryBuildOffloadedStatsPlan builds the aggregation plan, runs the offload rules, and returns the offloaded TransformSupport only when the WHOLE plan was offloaded -- every node except the StatisticsInputNode leaf is a TransformSupport (a root WholeStageTransformer is not sufficient, since ColumnarCollapseTransformStages can wrap an offloaded parent above a vanilla child). Otherwise it returns None and statistics are collected the row-based way through the existing GlutenDeltaJobStatsFallbackTracker. Native resources are allocated only on the accepted path. Add DeltaTimestampNtzStatsWriteSuite covering top-level and struct-nested TIMESTAMP_NTZ columns: the native write succeeds and Delta min/max statistics are still produced via the fallback. Generated-by: GitHub Copilot CLI (Claude Opus 4.8) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 66a9e40f-3ac8-45be-8fee-a606a22fa098
7d30ccb to
357aaf9Comparefelipepessoto
commented
Sep 4, 2026
Instead of adding the fallback, I'm adding support for timestamp_ntz aggregation: #12967 |
felipepessoto
commented
Sep 4, 2026
@Smallfu666, could you review these two PRs instead? #12967, #12966 |
What changes are proposed in this pull request?
Fixes#12538.
GlutenDeltaJobStatsTrackercollects Delta write statistics by building a local Velox aggregation plan and assuming it is always offloaded to aWholeStageTransformer. When the statistics plan references a type or expression Velox cannot offload — for example an aggregate over aTIMESTAMP_NTZcolumn — the offload rules reject it and leave a vanillaProjectExec, so the unconditional cast threw:failing the whole write.
This PR makes the Delta stats path fall back to row-based statistics collection when the plan cannot be fully offloaded, as suggested by rui-mo and zhztheplayer in 12388:
newTaskInstance(), where the native plan is actually built.tryBuildOffloadedStatsPlanbuilds the aggregation plan, runs the offload rules, and returns the offloadedTransformSupportonly when the whole plan was offloaded — every node except theStatisticsInputNodeleaf is aTransformSupport. A rootWholeStageTransformeralone is not sufficient, becauseColumnarCollapseTransformStagescan wrap an offloaded parent above a vanilla child.Noneand statistics are collected the row-based way through the existingGlutenDeltaJobStatsFallbackTracker. Native resources (the single-thread executor andNativePlanEvaluator) are allocated only on the accepted path.Both the Delta 3.3 (
src-delta33) and Delta 4.0+ (src-delta40) variants are updated.How was this patch tested?
Added
DeltaTimestampNtzStatsWriteSuite(bothsrc-delta33andsrc-delta40), which writes a Delta table with a top-level and a struct-nestedTIMESTAMP_NTZcolumn through the native write path with statistics collection enabled. Without the fix the write throws theClassCastExceptionabove; with it the write succeeds, the data reads back correctly, and DeltaminValues/maxValuesstatistics are still produced for theTIMESTAMP_NTZcolumn via the fallback.Compiles for
-Pspark-4.1(delta40) and-Pspark-3.5(delta33).Was this patch authored or co-authored using generative AI tooling?
Generated-by: GitHub Copilot CLI (Claude Opus 4.8)