Writing data to open table formats
In the previous guides, you queried open table formats in place and loaded data into MergeTree for fast analytics. In many architectures, data also needs to flow in the other direction - from ClickHouse back into lakehouse formats. Two common scenarios drive this:
- Offloading to long-term storage - Data arrives in ClickHouse as a real-time analytics layer, powering dashboards and operational reporting. Once the data ages beyond its real-time window, it can be written out to Iceberg in object storage for durable, cost-effective retention in an interoperable format.
- Reverse ETL - Transformations, aggregations, and enrichment performed inside ClickHouse produce derived datasets that downstream tools and other teams need to consume. Writing these results to Iceberg tables makes them available across the broader data ecosystem.
In both cases, INSERT INTO SELECT lets you move data from ClickHouse tables into Iceberg tables stored in object storage.
Writing to open table formats is currently supported for Iceberg tables only. Partial support for Delta Lake tables is under development. Tables must not be managed by a catalog.
Prepare a source dataset
For this guide, we'll use the UK Price Paid dataset - a public record of every residential property transaction in England and Wales.
Create and populate a MergeTree table
Populate the table directly from the public CSV source:
Write data to an Iceberg table
Create the Iceberg table
To write data into Iceberg, create a table using the IcebergS3 table engine.
Note that the schema must be simplified compared to the MergeTree source. ClickHouse supports a richer type system than Iceberg and the underlying Parquet files - types such as Enum, LowCardinality, and UInt8 are not supported in Iceberg and must be mapped to compatible types.
Insert a subset of data
Use INSERT INTO SELECT to write data from the MergeTree table into the Iceberg table. In this example, we write only London transactions:
Query the Iceberg table
The data is now stored as Iceberg in object storage and can be queried from ClickHouse - or any other tool that reads Iceberg:
Write aggregated results
Iceberg tables are not limited to storing raw rows. They can also hold the output of aggregations and transformations - the results of ETL processes performed inside ClickHouse. This is useful for publishing pre-computed summaries to a lakehouse for downstream consumption.
Create an Iceberg table for aggregates
Insert aggregated data
Compute average property prices by town and write the results directly into Iceberg:
Query the aggregated table
Other tools - and other ClickHouse instances - can now read this pre-computed dataset: