Repository navigation
[GLUTEN-13500][VL] [Blocked on #13135] Support Delta partition column materialization - #13502
felipepessoto wants to merge 9 commits into
Conversation
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
1 similar comment
|
Run Gluten Clickhouse CI on x86 |
de0e082 to
69706f4
Compare
|
Run Gluten Clickhouse CI on x86 |
69706f4 to
45b16ab
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Delta partition-column materialization changes.
No open issues 🎉
What changed in this PR
Enables Velox native writes for Delta partition-column materialization on Spark 4.x, including Delta 4.4’s default partitioned writes, while retaining unsupported-case fallbacks.
Changes:
- Passes partition-column retention through Scala, Java, and JNI, preserving Delta’s file-schema order and excluding partition columns from statistics.
- Adds coverage for feature/property precedence, physical Parquet contents, writer identity, mixed-file reads, and UPDATE/DELETE behavior.
- Updates support documentation and restores ten known failures exposed by native execution.
| File | Description |
|---|---|
gluten-ut/spark35/src-delta/test/scala/org/apache/spark/sql/execution/datasources/GlutenDeltaNativePartitionWriteSuite.scala |
Tests materialized columns, reordered keys, nulls, file limits, and statistics. |
docs/backends/velox/get-started/VeloxDelta.md |
Documents materialization support and remaining type restrictions. |
cpp/velox/jni/VeloxJniWrapper.cc |
Retains partition columns after data columns when requested. |
backends-velox/src/main/scala/org/apache/spark/sql/execution/datasources/velox/VeloxFormatWriterInjects.scala |
Forwards the partition-retention flag to JNI. |
backends-velox/src/main/java/org/apache/gluten/datasource/VeloxDataSourceJniWrapper.java |
Adds the partition-retention argument to the native interface. |
backends-velox/src-delta4/test/scala/org/apache/spark/sql/delta/DeltaNativeWriteSuite.scala |
Exercises Delta’s default partition-column behavior. |
backends-velox/src-delta4/test/scala/org/apache/gluten/execution/VeloxDelta4WriteSuite.scala |
Tests precedence, interoperability, rewrite operations, and mapping fallbacks. |
backends-velox/src-delta4/test/scala/org/apache/gluten/delta/GlutenDeltaNativeWriteGateSuite.scala |
Tests materialization eligibility and retained restrictions. |
backends-velox/src-delta4/main/scala/org/apache/spark/sql/delta/GlutenDeltaNativeWriteGate.scala |
Allows materialization while rejecting unsupported partition types. |
backends-velox/src-delta4/main/scala/org/apache/spark/sql/delta/files/GlutenDeltaFileFormatWriter.scala |
Retains partition columns for writing and projects data-only statistics batches. |
.github/workflows/util/delta-spark-ut/known-failures.txt |
Restores eight exception-contract and two concurrent OPTIMIZE failures. |
Review effort: Balanced
|
Hi @malinjawi, @zhztheplayer, and @zhouyuan could you review this PR? It adds native partition-column materialization (enabled by default in 4.4), allowing supported Delta 4.4 partitioned writes to run natively instead of falling back. |
|
Run Gluten Clickhouse CI on x86 |
There was a problem hiding this comment.
Thanks @felipepessoto , looks good overall. The column order, stats exclusion and batch ownership all check out. A few points:
- CHECK and NOT NULL violations on default partitioned tables now lose Delta's exception type too, not just replaceWhere. Worth noting, and it overlaps with #13133.
- Writes to file systems the native writer can't handle (e.g. s3a without S3 support) now fail instead of falling back. My draft #13386 adds that check to the gate.
- CDF DML now runs native even on unpartitioned tables (
__is_cdc). The output matches Delta, but it could use a mention and a small test.
Smaller gaps: no file-level test for OPTIMIZE on materialized tables, and no Spark 4.x CI job runs DeltaNativeWriteSuite.
|
@malinjawi Pushed e57998b with the review follow-ups. The inline replies cover the timestamp guard and direct UPDATE/DELETE file reads. I also added partitioned and unpartitioned CDF UPDATE/DELETE cases that inspect both data and change Parquet files and compare the rows with vanilla Delta, plus an OPTIMIZE case that requires real file replacement and checks the new files, partition values, and statistics. The docs now explain the virtual __is_cdc partition and the wider CHECK/NOT NULL exception impact. DeltaNativeWriteSuite is now explicitly included in group 1 of the existing Spark 4.0/4.1/4.2 CI jobs. I checked the actual parallel-UT discovery output: only that suite is added, with no existing suites lost. All 59 focused tests passed locally on Spark 4.1, including its 12 tests; fresh CI is pending. The generic JNI fix remains in #13133, where combined strict Delta constraint validation is being added separately. I also followed up on #13386 about checking connector build availability as well as URI schemes. Neither exception preservation nor filesystem fallback is claimed fixed by this PR. |
|
Run Gluten Clickhouse CI on x86 |
There was a problem hiding this comment.
🔵 Needs a closer look
Shared JNI splitting and asynchronous statistics-batch ownership now affect default partitioned Delta writes, warranting human review of persisted-file compatibility while full native/Spark 4.0–4.2 validation remains pending.
No open issues 🎉
Review effort: Balanced
malinjawi
left a comment
There was a problem hiding this comment.
Thanks @felipepessoto, this covers everything I raised. Falling back on TIMESTAMP partitions in both modes is the safe call, and I like that the UPDATE/DELETE, CDF and OPTIMIZE tests now check the actual Parquet files. Nice to see DeltaNativeWriteSuite running on 4.0, 4.1 and 4.2 as well. Leaving the exception types to #13133 and the filesystem side to #13386 makes sense to me.
Small optional nit: in VeloxDelta.md, the sentence saying CI checks partitioned save(path) on 3.5 to 4.1 and OPTIMIZE on 3.5 is a bit out of date now that the next line adds the 4.0, 4.1 and 4.2 jobs.
LGTM!
1710bcf to
ab1c25d
Compare
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore the ten failures removed by e920e70 when partitioned writes fell back to Delta. Materializing partition columns re-exposes existing JNI exception-loss and custom-filesystem limitations; record them without changing production behavior or test assertions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Guard TIMESTAMP partition splitting independently of materialization; verify physical UPDATE, DELETE, CDF and OPTIMIZE outputs; and select DeltaNativeWriteSuite in Spark 4.x CI. Document the existing constraint exception and filesystem limitations without duplicating their separate fixes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the materialization caveats consistent with upstream's NOT NULL exception recovery; CHECK and replaceWhere still require generic JNI preservation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve the merged filesystem eligibility gate and exercise fallback for default and feature-forced materialization, including OPTIMIZE and physical partition values. Refresh the remaining JNI dependency caveat. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Both original upstream concurrent OPTIMIZE cases pass with the merged filesystem fallback and materialization. Keep the eight replaceWhere exception-contract cases until iterator preservation is integrated. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
d28b3f3 to
db5d719
Compare
|
Run Gluten Clickhouse CI on x86 |
|
@zhztheplayer FYI, we are waiting for #13133 first, and merge this after it: #13502 (comment) |
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
db5d7193f07a444957ba9b8716c68d2ea48d0291↑ Pre-rebase Delta CI passed all eight shards; matching integration builds passed 47 backend and 28 upstream OPTIMIZE cases.
↓ Eight known JNI exception-contract cases remain pending #13561.
↓ New-head CI is pending; no local native/Spark rebuild was run for this mechanical rebase. Prior CI exposed the streaming TTL race and a ClickHouse AQE build-side assertion, neither fixed here.
What changes are proposed in this pull request?
Fixes #13500.
Enable Velox native writes for Delta's Materialize Partition Columns feature on Spark 4.x.
This also enables native file writing for default Delta 4.4 partitioned tables. Delta defaults
delta.writePartitionColumnsToParquettotruewhen unset, independently of the protocol feature. Previously, Gluten sent these writes to Delta's JVM writer even with native writes enabled. Reads could still run in Velox, so passing correctness tests or aGlutenDeltaplan node did not prove native file-write coverage.false.Column mapping, UniForm, and other existing unsupported combinations still fall back. FLOAT/DOUBLE partition columns fall back explicitly. TIMESTAMP partition columns fall back regardless of materialization or actual value precision because the splitter cannot represent sub-millisecond values; timestamp data columns retain their existing encoding checks. Delta 3.3 behavior is unchanged.
CDF UPDATE/DELETE can also execute natively on unpartitioned tables because Delta routes change rows through the virtual
__is_cdcpartition. Tests now inspect both data and change files and compare with vanilla Delta. Physical-file checks cover OPTIMIZE as well as UPDATE/DELETE, and Spark 4.0/4.1/4.2 CI explicitly selectsDeltaNativeWriteSuite.Filesystem prerequisite resolved: this branch is rebased onto main
b6fbc82d, including merged #13386. On Spark 4.x, unsupported schemes and connectors unavailable in the native build use Delta's writer, including materialized writes and OPTIMIZE. New physical-file cases cover both default materialization and feature-forced materialization with the property set tofalse. Both original concurrentOPTIMIZEcases usingblock:now pass unchanged, so their two known-failure entries are removed. The filesystem fix is inherited from main, not duplicated here.Remaining known failures: retain the eight
replaceWhereexception-contract entries originally removed by e920e70e4 when partitioned writes began falling back. CHECK andreplaceWherefailures can still lose their original exception across native iterators; constraints remain enforced and rejected writes commit nothing. Main already contains core JNI transport (#13560) and separate NOT NULL exception recovery, but iterator preservation in #13561 remains open. #13133 is the combined reference, not an additional PR to merge. Keep these eight entries until the remaining fix is integrated and the exact cases pass. Native/fallback coverage detection is tracked separately in #13504.Historical combined validation of this PR at
45b16ab55with #13133's JNI implementation atf88c2698passed 12 strict constraint cases and all eight unchanged upstream replaceWhere cases, checking original Delta exception metadata and unchanged table version/files/rows after rejection. Default and feature-forced materialization were covered; the materialization-only control failed the partitioned exception-contract cases. Regression coverage was published separately in #13133, commit 00c478419. These are prior-combination results, not a claim that the pending iterator fix is present in this branch.How was this patch tested?
Rebase
db5d7193fonto mainb6fbc82d: all nine commits have identical patches, and all 12 PR files retain their pre-rebase contents. License-header and whitespace checks passed. No local native/Spark rebuild was run for this mechanical rebase; new-head CI is pending.Before the rebase,
d28b3f310: Delta CI passed all eight shards and aggregation. The x86 rerun failed one Spark 4.2GlutenTransformWithStateAvroSuiteTTL-restart case: the first attempt failed with changelog checkpointing, while the retry passed that variant and failed without changelog checkpointing. The schema-error stack matches the previously observed streaming test race. All 62 Delta cases in that job passed; no streaming test was changed or excluded. The authenticated ClickHouse console log identifies its sole failure in Spark35 UT:ClickHouseAdaptiveQueryExecSuite,Gluten - metrics of the shuffle read, withBuildRight did not equal BuildLeftat line 767. The test expected the broadcast join to build on the left, but AQE selected the right. This suite is unchanged by the PR; the underlying cause of that plan choice has not been established. The earlier HTTP 403 was from an unauthenticated request, not an inability to access the documented read-only CI service. These are prior-head results, not current-head CI success.Filesystem integration,
ab1c25dda: 47 backend cases and 28 upstream OPTIMIZE cases passed, with no failures, skips, or aborted suites. The subsequentd28b3f310follow-up changed only the two verified baseline entries.5af65754046c5f4f9bd56ac5081570f9a7dd02e4was verified to have base04597a05and PR headab1c25dda.GlutenDeltaNativeWriteGateSuite: 23 passed, including unsupported schemes, compiled-out connectors, and failed native-probe handling.VeloxDelta4WriteSuite: 24 passed, including the two new materialization/filesystem cases. Those cases verify JVM Parquet writer identity, physical partition values, successful OPTIMIZE file replacement, and all rows before/after compaction; existing supported-filesystem native checks remain enabled.OptimizeCompactionSuite.scalawith that run's matching bundle: 27 SQL cases plus the selected Scala concurrency case passed. Both exactoptimize - multiple jobs start executing at onceidentities are present in successful JUnit reports. Replaying the normal enforcement script with the updated baseline passed. No assertions were weakened and no quarantine entries were added.Earlier review follow-up
e57998b8c: 59 focused tests passed on Spark 4.1 / Scala 2.13 / JDK 17 in the preserved DevContainer:GlutenDeltaNativeWriteGateSuite(19),VeloxDelta4WriteSuite(20),DeltaNativeWriteSuite(12), andGlutenDeltaNativePartitionWriteSuite(8). JVM modules were rebuilt against the native libraries from the successful then-current-base CI build; that follow-up changed no JNI/C++ source.Coverage verifies physical partition values after UPDATE/DELETE, data and change files for partitioned/unpartitioned CDF DML, rewritten native OPTIMIZE files, and sub-millisecond TIMESTAMP fallback with materialization both on and off. Existing precedence, null/reordered-key, file-limit, statistics, mixed-file, and fallback checks remain enabled.
Recorded Maven forks were passed through the actual parallel-UT discovery code: the new group-1 selector adds exactly
DeltaNativeWriteSuiteinbackends-velox, preserves every prior suite, and adds nothing in the unrelated Spark UT module. Its 12 tests also executed successfully. YAML checks verify selection only in group 1 across Spark 4.0/4.1/4.2. These are historical selection checks, not a substitute for the current-head CI matrix.Prior CI on
69706f449passed all 83 executed GitHub checks (two skipped), all eight Delta shards and aggregation, and external ClickHouse CI. That historical result is not a claim that current-head CI is green. Delta CI enforces known failures; a green gate does not mean every upstream test passes.Before/after execution
The write changes from row conversion for Delta's JVM writer to native batches for Velox's writer; the Parquet footer independently confirms the writer used.
Executed writer-input plans and Parquet footer evidence
Same input on Spark 4.1.1 / Delta 4.4.1, appended with
data.write.format("delta").mode("append").save(path)to a table partitioned bypart:Both runs enabled native writes and the
materializePartitionColumnswriter feature, withdelta.writePartitionColumnsToParquet=falseto exercise feature precedence. AQE and optimized writes were disabled for a compact, deterministic example.Before:
DeltaFileFormatWriter(JVM fallback)After:
GlutenDeltaFileFormatWriter(native)These are the plans actually consumed by the writers, captured through their existing
executedPlantest hooks, not just the input DataFrame'sexplain()output. The outer command isExecute GlutenDelta SaveIntoDataSourceCommandin both runs.VeloxColumnarToCarrierRowcarries native batches through the row-based writer interface rather than materializing every row.The example has no row constraints. Omitting its no-op
DeltaInvariantCheckeris an existing native-path optimization, not a change introduced here; the checker is retained when constraints exist.created_byparquet-mr version 1.16.0id,value,partparquet-cpp-velox version 0.0.0id,value,partBoth standalone
part=1files contain(1, row-1, 1),(3, row-3, 1), and(5, row-5, 1), withpartphysically stored as INT32. Spark and independent PyArrow reads agree. Delta's fallback already wrote correct materialized files; the improvement is native execution, not different data.Capture provenance: matched pre-rebase CI bundles: main
1ac8f880versus PR head69706f449, tested as merge8fff74dconto that same main. The materialization implementation is unchanged in rebased head45b16ab55; these captures are not represented as executions of that newer build.Was this patch authored or co-authored using generative AI tooling?
Generated-by: GitHub Copilot 1.0.102-0.unstable.r40141230562.g130d689 (GPT-6 Astra / gpt-6-astra)