Skip to content

Export the Delta Lake commit metadata without the Apache Arrow C++ library - #131768

Merged
alexey-milovidov merged 5 commits into
masterfrom
delta-lake-writes-without-arrow
Nov 18, 2026
Merged

alexey-milovidov merged 5 commits into
masterfrom
delta-lake-writes-without-arrow

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Part of removing the Apache Arrow C++ library: Delta Lake writes no longer use it.

WriteTransaction::commit gave delta-kernel the add-file records of a commit (path, partition values, size, modification time, numRecords stats) as an Arrow record batch built with CHColumnToArrowColumn and exported with Arrow's C bridge. This adds a native exporter to the Arrow C data interface, ArrowIPC/ArrowCData, and uses it instead.

The exporter does not need Arrow-specific encoding code of its own. It runs RecordBatchEncoder and buildSchemaMessage, the encoder and schema builder of the native Arrow output format. Then it wraps the resulting pre-ordered field nodes and buffers into a tree of ArrowArrays and the parsed schema into ArrowSchemas, following the buffer layout that RecordBatchDecoder::advanceField walks. The arrays share one reference-counted body and can be moved and released independently, as the C data interface requires. LowCardinality is exported as plain values. The Arrow types are the ones the Arrow format writes, which match what CHColumnToArrowColumn produced for these columns (entries/key/value map fields included). Metadata too large for one record batch is still added as several batches, now split with maxRowsFittingOneArrowBatch.

The Vortex format will use the same exporter when it moves off the Arrow library.

Tested locally: the 31 stateless tests that write to Delta Lake tables pass, except the parts that need S3 (no MinIO in my environment).

Delta Lake still needs the Arrow library for reading the change data feed until #130062 is merged; after that, USE_DELTA_KERNEL_RS can stop requiring ch_contrib::parquet.

Related: #130062
Related: #131763

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/131768]

Version info

  • Merged into: 26.11.1.2778-master (included in 26.11 and later)

alexey-milovidov and others added 2 commits November 15, 2026 00:58
…brary

`WriteTransaction` gave delta-kernel the add-file records of a commit as an Arrow
record batch built with `CHColumnToArrowColumn` and exported with Arrow's C bridge.
Add a native exporter to the Arrow C data interface (`ArrowIPC/ArrowCData`) that
wraps the buffers of `RecordBatchEncoder`, the encoder of the native `Arrow`
format, and use it instead. The Arrow types are the ones the `Arrow` format writes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c2cda91]

Summary: ✅


AI Review

Summary

The PR replaces Apache Arrow C++ conversion of Delta Lake commit metadata with an Arrow C data exporter backed by the native encoder. The previous allocation-failure leak is addressed by owning children before building them. No new actionable findings remain. The exported representation's consumers are WriteTransaction::commit, kernel get_engine_data, and transaction add_files; the metadata layout and shared buffer ownership remain compatible with these paths.

Missing context / blind spots
  • ⚠️ No local ClickHouse build or binary was available, so tests were inspected but not rerun. The author reports running 31 Delta Lake write tests locally, excluding S3-dependent portions. The current head's targeted sanitizer tests are pending in CI; those results will verify the callback-type correction under sanitizers.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c2cda9195 with master 68084c953 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

5 object files changed (+133.64 KiB total), 1 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/ArrowIPC/ArrowCData.cpp.o new 164.54 KiB +164.54 KiB
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/DeltaLake/WriteTransaction.cpp.o 293.82 KiB 262.93 KiB -30.89 KiB (-10.51%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

9 translation units recompiled, 16 s compile time in total, 8 of them have a recent master baseline.

Job report

alexey-milovidov and others added 3 commits November 18, 2026 17:03
`WriteTransaction::commit` declared the exported structs as the kernel's
`ffi::FFI_ArrowSchema`/`ffi::FFI_ArrowArray` and called their `release`
callbacks through those types, while the callbacks are defined for
`ArrowSchema`/`ArrowArray`. UBSan (`-fsanitize=function`) reports this as
"call to function ... through pointer to incorrect function type", which
failed every Delta Lake write in the sanitizer builds. Declare the structs
with the C data interface types and cast only when passing them to the kernel.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131768&sha=latest&name_0=PR
PR: #131768

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…them throws

The children of an exported `ArrowSchema`/`ArrowArray` were built into a
temporary `unique_ptr` and only then pushed into the parent's vector. If the
push threw (e.g. `MEMORY_LIMIT_EXCEEDED` from `VectorWithMemoryTracking`), the
child's `release` callback was never called and its `ExportedArray` kept the
shared batch body alive. Insert the zero-initialized child into the parent
first and build it in place: the parent's destructor then releases it, and a
child whose build threw has no `release` set and is just freed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the best looking code, but it is required for this purpose.

@alexey-milovidov alexey-milovidov self-assigned this Nov 18, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 18, 2026
Merged via the queue into master with commit cf7ef0b Nov 18, 2026
194 checks passed
@alexey-milovidov
alexey-milovidov deleted the delta-lake-writes-without-arrow branch November 18, 2026 21:49
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 18, 2026
@clickhouse-gh clickhouse-gh Bot added comp-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-delta-lake Delta Lake tables: reading Delta metadata through delta-kernel-rs (table snapshots, schema and ty... pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants