Skip to content

DeltaLake: Use new create table transaction - #106011

Merged
SmitaRKulkarni merged 102 commits into
masterfrom
add_create_table_deltalake
Sep 15, 2026
Merged

SmitaRKulkarni merged 102 commits into
masterfrom
add_create_table_deltalake

Conversation

@SmitaRKulkarni

@SmitaRKulkarni SmitaRKulkarni commented May 27, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Support CREATE TABLE ... ENGINE = DeltaLake(...) to create a new Delta Lake table (writing the initial commit via delta-kernel-rs), attach to an existing _delta_log, or register an existing table into a Unity catalog. Gated behind the new allow_delta_lake_create_table setting; creating a partitioned table (PARTITION BY) is not supported yet. Writes to a Delta Lake table now cast values to the Delta write-schema type with an accurate cast that throws when a value does not fit the target type (e.g. 300 written into a Delta byte) instead of silently truncating; the new delta_lake_accurate_write_cast setting (default enabled) controls this, and compatibility below 26.9 restores the previous truncating behaviour.

Closes: #103155
Related: #105861


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

Version info

  • Merged into: 26.9.1.1517 (included in 26.9 and later)

@SmitaRKulkarni
SmitaRKulkarni marked this pull request as draft May 27, 2026 21:12
@clickhouse-gh

clickhouse-gh Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [debb618]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan_ubsan, targeted) FAIL
03710_analyzer_limit_by_aggregate_validation FAIL cidb

AI Review

Summary

This PR adds CREATE TABLE support for DeltaLake/DeltaLakeLocal, catalog registration in Unity, and stricter write-schema casting. The core create/register flow is much closer now, but there are still a few contract breaks around schema persistence: complex outer Nullable wrappers are still lost on schema reload, Unity onboarding still strips semantics-bearing Delta field metadata, and catalog-backed CREATE TABLE still accepts ClickHouse-only metadata it cannot persist.

Findings
❌ Blockers
  • [src/Storages/ObjectStorage/DataLakes/DeltaLake/getSchemaFromSnapshot.cpp:483-555, src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadata.cpp:84-120, 806-809] The new create path now serializes outer nullable for Array / Map / Tuple, but both schema readers still drop that wrapper when they reconstruct the type. Nullable(Array(...)), Nullable(Map(...)), and Nullable(Tuple(...)) therefore reattach as non-nullable after a kernel schema reload or a Unity/catalog lookup, so the PR's new "Nullable and their combinations" contract does not round-trip.
    Suggested fix: either reject outer-Nullable complex types in DeltaLake CREATE TABLE, or wrap reconstructed complex types back in Nullable in both SchemaVisitorData::getNamesAndTypesFromList and DeltaLakeMetadata::getFieldType.
  • [src/Storages/ObjectStorage/DataLakes/DeltaLake/getSchemaFromSnapshot.cpp:701-710, src/Storages/ObjectStorage/DataLakes/DeltaLake/DeltaLakeCatalogRegistration.cpp:41-47] Registering an existing Delta table into Unity still strips arbitrary field metadata even though the repo already treats some of it as semantics-bearing. getRawDeltaSchemaFields hardcodes every field's metadata to {}, and registerDeltaTableInCatalog only rejects column-mapping and CHAR/VARCHAR cases, so Spark-created tables with other metadata such as generated/identity-column markers are still registered with a schema that differs from the _delta_log.
    Suggested fix: preserve field metadata when building the raw Delta schema, or fail closed on any non-empty field metadata instead of only the currently special-cased keys.
  • [src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadataDeltaKernel.cpp:834-839, src/Storages/ObjectStorage/StorageObjectStorage.cpp:359-360, src/Databases/DataLake/DatabaseDataLake.cpp:972-991] Catalog-backed CREATE TABLE still accepts CHECK constraints even though later lookups rebuild the table with ConstraintsDescription{} and no persisted local metadata. The statement can therefore succeed with CONSTRAINT ... CHECK ..., but the constraint disappears from the next lookup and later inserts stop enforcing it.
    Suggested fix: reject table constraints on catalog-backed DeltaLake CREATE TABLE, or persist a ClickHouse-side override for catalog tables.
⚠️ Majors
  • [src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadataDeltaKernel.cpp:842-853, src/Databases/DataLake/DatabaseDataLake.cpp:764, 972-991] Explicit-column onboarding into a Unity DataLakeCatalog still accepts schemas it does not preserve. On an existing Delta table the create path registers the snapshot's Delta schema, while later lookups rebuild the ClickHouse table from table_metadata.getSchema() only, so a DDL like CREATE TABLE db.\ns.t` (id Int32, bogus String) ENGINE = DeltaLakeLocal(existing_path)` can succeed even though the declared schema is discarded immediately.
    Suggested fix: reject explicit-column catalog onboarding unless the declared schema exactly matches the schema that will be registered, or persist a ClickHouse-side schema override.
Tests
  • No coverage exercises catalog-backed CREATE TABLE with table constraints, so the new DDL surface does not currently pin down that unsupported metadata is rejected instead of being silently dropped.
Final Verdict

❌ Changes requested.

LLVM Coverage Report

Measured on commit debb618.

Metric Baseline Current Δ
Lines 89.10% 89.10% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.50% 81.50% +0.00%

Changed lines: Changed C/C++ lines covered: 648/779 (83.18%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-feature Pull request with new product feature submodule changed At least one submodule changed in this PR. labels May 27, 2026
SmitaRKulkarni and others added 2 commits June 29, 2026 10:24
`getInMemoryMetadataPtr` returns a `StorageMetadataHandle` by value. Its
rvalue `operator->` is deleted to prevent the reference returned by
`getColumns` from dangling. Store the handle in a local variable so it
outlives the `columns` reference.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@SmitaRKulkarni
SmitaRKulkarni marked this pull request as ready for review July 7, 2026 09:36
@mintlify

mintlify Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Sep 15, 2026, 5:52 AM

}

/// A catalog-backed table is rebuilt from the registered Delta schema, which cannot carry a DEFAULT expression; reject rather than silently drop it. Plain tables keep it in their own metadata.
if (register_with_catalog && columns->hasDefaults())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DEFAULT is not the only ClickHouse-side contract that this catalog path cannot preserve. StorageObjectStorage still stores constraints_ in the transient table object built for the DDL, but every later catalog lookup rebuilds the table with ConstraintsDescription{} and no local metadata in DatabaseDataLake::tryGetTableImpl (src/Storages/ObjectStorage/StorageObjectStorage.cpp:359-360, src/Databases/DataLake/DatabaseDataLake.cpp:972-991).

That means CREATE TABLE db.\ns.t` (x Int32 CONSTRAINT c CHECK x > 0) ENGINE = DeltaLake...succeeds here, then the constraint disappears on the next lookup and later inserts stop enforcing it. Please rejectCHECKconstraints on catalog-backedDeltaLake CREATE TABLEalongsideDEFAULT`, or persist a ClickHouse-side override for catalog tables.

@clickhouse-gh

clickhouse-gh Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 39 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 07bb517d-cb60-4562-a1b6-57348978d004
  • MIRAI run: 4bac86f6-759c-4640-bd1d-14df258d36ea
  • PR check IDs:
    • clickbench_260072_1789458485
    • clickbench_260084_1789458485
    • clickbench_260091_1789458485
    • tpch_adapted_1_official_260097_1789458485
    • tpch_adapted_1_official_260128_1789458485
    • tpch_adapted_1_official_260142_1789458485

@SmitaRKulkarni
SmitaRKulkarni added this pull request to the merge queue Sep 15, 2026
Merged via the queue into master with commit b9cf1db Sep 15, 2026
175 of 177 checks passed
@SmitaRKulkarni
SmitaRKulkarni deleted the add_create_table_deltalake branch September 15, 2026 10:05
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 15, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@SmitaRKulkarni @kssenii — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

@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

This branch was successfully deployed

1 active deployment
staging - docs — debb6186 Deployed Sep 15, 2026 by mintlify[bot]
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-experimental Experimental Feature 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.

Implementing CREATE TABLE for DeltaLake engine

7 participants