You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
[Feature] Support TRUNCATE TABLE for Iceberg Engine
Overview
As part of the Antalya release, v26.1 needs to natively support the TRUNCATE TABLE command for the Iceberg database engine. Currently, upstream ClickHouse explicitly rejects this operation. As of PR #91713, executing TRUNCATE down-casts to StorageObjectStorage, where it immediately throws an ErrorCodes::NOT_IMPLEMENTED exception for Data Lake engines.
To support standard analytics workflows and testing pipelines without requiring users to DROP and recreate tables (which breaks catalog bindings), implementing a metadata-only truncation is essential.
Proposed Architecture
Unlike a standard MergeTree truncation that physically drops parts from the local disk, Iceberg truncation must be entirely logical. The implementation will leave physical file garbage collection to standard Iceberg maintenance operations and focus strictly on metadata manipulation.
Core Workflow:
Bypass the Upstream Block: Modify StorageObjectStorage::truncate to check data_lake_metadata->supportsTruncate().
Snapshot Generation: Generate a new Iceberg snapshot ID and increment the metadata version (v<N+1>.metadata.json).
Empty Avro Manifest List: The new snapshot cannot simply omit the manifest list. We must use ClickHouse's internal object storage and Avro APIs to generate and write a strictly typed, empty Avro manifest list to object storage.
Metadata Update: Attach the new empty manifest list to the new snapshot, append the snapshot to the snapshots array, and update the snapshot-log and current-snapshot-id.
Catalog Commit: Perform an atomic swap via the ICatalog interface (e.g., REST Catalog) to point the table to the newly generated metadata JSON.
Implementation Details
The required changes span the following internal abstractions:
src/Storages/ObjectStorage/StorageObjectStorage.h/cpp: Override truncate and remove the hardcoded throw Exception. Delegate to IDataLakeMetadata.
src/Storages/ObjectStorage/DataLakes/IDataLakeMetadata.h: Introduce supportsTruncate() and truncate(ContextPtr, ICatalog) virtual methods.
src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.h/cpp: Implement the core truncation logic. Must safely obtain an IObjectStorage write buffer via context->getWriteSettings() to serialize the empty Avro file before committing the JSON metadata.
[Feature] Support TRUNCATE TABLE for Iceberg Engine
Overview
As part of the Antalya release, v26.1 needs to natively support the
TRUNCATE TABLEcommand for the Iceberg database engine. Currently, upstream ClickHouse explicitly rejects this operation. As of PR #91713, executingTRUNCATEdown-casts toStorageObjectStorage, where it immediately throws anErrorCodes::NOT_IMPLEMENTEDexception for Data Lake engines.To support standard analytics workflows and testing pipelines without requiring users to
DROPand recreate tables (which breaks catalog bindings), implementing a metadata-only truncation is essential.Proposed Architecture
Unlike a standard MergeTree truncation that physically drops parts from the local disk, Iceberg truncation must be entirely logical. The implementation will leave physical file garbage collection to standard Iceberg maintenance operations and focus strictly on metadata manipulation.
Core Workflow:
StorageObjectStorage::truncateto checkdata_lake_metadata->supportsTruncate().v<N+1>.metadata.json).snapshotsarray, and update thesnapshot-logandcurrent-snapshot-id.ICataloginterface (e.g., REST Catalog) to point the table to the newly generated metadata JSON.Implementation Details
The required changes span the following internal abstractions:
src/Storages/ObjectStorage/StorageObjectStorage.h/cpp: Overridetruncateand remove the hardcodedthrow Exception. Delegate toIDataLakeMetadata.src/Storages/ObjectStorage/DataLakes/IDataLakeMetadata.h: IntroducesupportsTruncate()andtruncate(ContextPtr, ICatalog)virtual methods.src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.h/cpp: Implement the core truncation logic. Must safely obtain anIObjectStoragewrite buffer viacontext->getWriteSettings()to serialize the empty Avro file before committing the JSON metadata.Acceptance Criteria