Skip to content

Native CREATE TABLE / DROP TABLE for DataLakeCatalog; optionally prune on DROP - #98670

Open
zvonand wants to merge 80 commits into
ClickHouse:masterfrom
zvonand:zvonand-create-iceberg-table
Open

zvonand wants to merge 80 commits into
ClickHouse:masterfrom
zvonand:zvonand-create-iceberg-table

Conversation

@zvonand

@zvonand zvonand commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

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

Supports CREATE TABLE, CREATE TABLE … AS source, and DROP TABLE for DataLakeCatalog; DROP TABLE can request catalog-side data purge via the new data_lake_delete_data_on_drop setting.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

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

@zvonand
zvonand force-pushed the zvonand-create-iceberg-table branch from 5133bc3 to a81e99e Compare March 4, 2026 17:59
@zvonand zvonand changed the title Allow to create Iceberg table in a DataLakeCatalog and allow to prune such tables on DROP. Support Iceberg table creation in DataLakeCatalog; optionally prune them on DROP Mar 26, 2026
@alesapin alesapin added the can be tested Allows running workflows for external contributors label Mar 26, 2026
@alesapin alesapin self-assigned this Mar 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f3c6b87]

Summary: ❌

job_name test_name status info comment
Style check FAIL
cpp FAIL cidb
Build (arm_tidy, 1/4) FAIL
Build ClickHouse FAIL cidb
Build (arm_tidy, 2/4) FAIL
Build ClickHouse FAIL cidb
Build (arm_tidy, 3/4) FAIL
Build ClickHouse FAIL cidb
Build (arm_tidy, 4/4) FAIL
Build ClickHouse FAIL cidb
Code Review DROPPED
Fast test (arm_darwin) DROPPED
Build (amd_debug) DROPPED
Build (amd_asan_ubsan) DROPPED
Build (amd_tsan) DROPPED

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Mar 26, 2026
@zvonand
zvonand force-pushed the zvonand-create-iceberg-table branch from b3846c8 to b381484 Compare March 26, 2026 15:10
@zvonand
zvonand force-pushed the zvonand-create-iceberg-table branch from b381484 to 97a60e7 Compare March 31, 2026 12:22
@alexey-milovidov

Copy link
Copy Markdown
Member

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
@zvonand zvonand changed the title Support Iceberg table creation in DataLakeCatalog; optionally prune them on DROP Native CREATE TABLE / DROP TABLE for DataLakeCatalog; optionally prune on DROP May 19, 2026
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
@CLAassistant

CLAassistant commented Nov 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread src/Databases/DataLake/GlueCatalog.cpp Resolved
zvonand and others added 4 commits November 9, 2026 15:17
…erg-table

Conflict resolutions:
- `master` added `IDatabase::maybeCreateTableInExternalCatalog`: an explicit Iceberg engine without
  arguments is created through a catalog that writes the first metadata file. It is kept as is; a
  `CREATE TABLE` without `ENGINE` still goes through this PR's `DatabaseDataLake::createTable`, and the
  removed `getDefaultTableEngineName` hook stays removed.
- `DatabaseDataLake`: keep this PR's `getNewTableLocation`, and port `master`'s handling of a namespace
  location that is not a URI (e.g. Databricks `not_used`) into it. Keep `master`'s
  `tryGetNewTableMetadata` and `checkStorageTypeMatchesEngine`, which `maybeCreateTableInExternalCatalog` uses.
- `RestCatalog::createTable`: use `master`'s `getCreateTableEndpoint` / `buildCreateTableRequestBody`
  and keep this PR's table name checks, `decodeTableName` and `IF NOT EXISTS` handling.
- `GlueCatalog`: `master` removed the timestamp type resolution and fills `StorageDescriptor.Columns`;
  keep this PR's `getIcebergMetadataObject`. The partition and sorting keys are now read before the
  schema, because the schema code returns early for tables with a metadata file.
- `ITableFunction::execute` was restructured on `master`; pass `canDeleteDataOnDrop` to the proxy there.
- `test_create_without_engine_arguments_namespace_location_not_a_uri`: drop the check that a
  `CREATE TABLE` without `ENGINE` reports `cannot tell where table`; this PR places such a table itself.
- Add `[[nodiscard]]` to the new getters and consume the results of validation-only calls that became
  `[[nodiscard]]` on `master`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- `05509_s3tables_catalog_sigv4_signed_headers`: a `CREATE TABLE` without `ENGINE` now checks
  whether the table exists before it registers the namespace. That `GET` carries no
  `X-Iceberg-Access-Delegation`, so the stub requires the header to be signed only when it is sent.
  The create still ends with `BAD_ARGUMENTS` after the signed namespace `POST`.
- `05562_create_table_deltalake_catalog_register_conflict`: `DataLakeCatalog` tables take only the
  location (plus the database engine arguments), so drop the redundant `Parquet` argument of
  `DeltaLakeLocal`. Otherwise the create is refused before it reaches the registration path the test covers.
- Remove `05394_iceberg_drop_temporary_table_delete_data`: `master` refuses temporary tables with
  engines that do not support them (74af670), `IcebergLocal` included.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=98670&sha=27370c82ed6da0e2cb6e95ee34e7d4d5015637f7&name_0=PR

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

Copy link
Copy Markdown
Member

🕵 I merged master again (18 conflicting files) and fixed the CI failures. Pushed as 531ab0084687 (merge) and f3c6b873131d (tests).

Merge decisions worth a look:

  • master added IDatabase::maybeCreateTableInExternalCatalog (from the Allow to create table without providing credentials if catalog specified #114477 follow-up). It creates an explicit Iceberg engine with no arguments through a catalog that writes the first metadata file. I kept it alongside this PR's path. CREATE TABLE without ENGINE still goes through DatabaseDataLake::createTable, and getDefaultTableEngineName stays removed.
  • getNewTableLocation now ignores a namespace location that is not a URI (e.g. Databricks not_used), the same way Treat a namespace location that is not a URI as no location in DataLakeCatalog CREATE TABLE #131238 does on master. In test_create_without_engine_arguments_namespace_location_not_a_uri I dropped the assertion that an engine-less create reports cannot tell where table, since this PR places such tables itself.
  • GlueCatalog::tryGetTableMetadata: master now returns early from the schema block for tables with a metadata file, so I moved this PR's partition and sorting key extraction ahead of it.
  • RestCatalog::createTable uses master's buildCreateTableRequestBody and keeps this PR's name check, decodeTableName and IF NOT EXISTS handling.

CI fixes:

  • 05509_s3tables_catalog_sigv4_signed_headers: an engine-less create now runs the existence check (GET .../tables/tbl, without X-Iceberg-Access-Delegation) before registering the namespace. The stub refused that request with 401. The stub now requires the header to be signed only when the request sends it. The create still ends with BAD_ARGUMENTS after the signed namespace POST.
  • 05562_create_table_deltalake_catalog_register_conflict: validateCreateTableEngineArguments refused DeltaLakeLocal(path, Parquet), so I dropped the redundant Parquet argument.
  • Removed 05394_iceberg_drop_temporary_table_delete_data: master (74af670) now refuses temporary IcebergLocal tables.

Both tests pass locally on the merged build, as do this PR's other stateless tests. I did not rerun the integration tests locally.

The open review thread about persisting the purge decision for deferred drop recovery still needs a decision from the authors (format of metadata_dropped vs UNDROP TABLE), so I left it open.

The decision captured by `prepareForDrop` lived only in the storage object, so a
drop still pending at a server restart was recovered by
`DatabaseCatalog::enqueueDroppedTableCleanup` without it, and the data of the
table was kept.

`DatabaseAtomic::dropTableImpl` now writes a marker file next to the dropped
metadata (`metadata_dropped/<db>.<table>.<uuid>.del`) when `deletesDataOnDrop`
is true, and removes a stale one otherwise. On recovery, a table with the marker
gets `prepareForDrop` again with `data_lake_delete_data_on_drop` enabled. The
marker is removed by `dropTableFinally` and `undropTable`; the dropped `.sql`
file itself is unchanged, so `UNDROP TABLE` is not affected.

Address review: ClickHouse#98670 (comment)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... external Author is not a member of the ClickHouse organization pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants