Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3f47047
vibe coded monotonicity check for mt -> iceberg exports
arthurpassos Jul 17, 2026
343c2d9
add some more tests
arthurpassos Jul 17, 2026
3f3af7c
make tests better
arthurpassos Jul 18, 2026
d385268
more vibe coded changes
arthurpassos Jul 20, 2026
454e9fc
recompute dst key with correct set of parts, include tz
arthurpassos Jul 20, 2026
abcba15
Merge branch 'antalya-26.3' into feature/antalya-26.3/export-partitio…
arthurpassos Jul 20, 2026
4e10ade
Merge branch 'antalya-26.3' into feature/antalya-26.3/export-partitio…
arthurpassos Jul 22, 2026
e4a69a0
some more vibe coded style changes
arthurpassos Jul 22, 2026
c60c97d
add missing tests
arthurpassos Jul 22, 2026
a9f51e1
code simplification
arthurpassos Jul 22, 2026
12c5e5b
some docs
arthurpassos Jul 22, 2026
ca43cf1
handle iceberg_timezone
arthurpassos Jul 24, 2026
56fde58
missing arg restore
arthurpassos Jul 24, 2026
ee1993a
docs
arthurpassos Jul 24, 2026
41fbe8f
opsy
arthurpassos Jul 24, 2026
450eddc
possible simplification
arthurpassos Jul 24, 2026
6df47c7
some more simplifications
arthurpassos Jul 27, 2026
1501cc7
add some comments
arthurpassos Jul 27, 2026
a89d2f0
simplifications and docs
arthurpassos Jul 27, 2026
776be0b
fix more vibe coded issues
arthurpassos Jul 27, 2026
7495ab6
further simplifications
arthurpassos Jul 27, 2026
e75220d
one more simplification
arthurpassos Jul 27, 2026
4285c90
fix tests
arthurpassos Jul 27, 2026
c439e33
rename variable
arthurpassos Jul 27, 2026
43096d4
opsy
arthurpassos Jul 27, 2026
78024e2
docs and style changes
arthurpassos Jul 27, 2026
2015f2a
more docs
arthurpassos Jul 27, 2026
ad1301f
shitty changes
arthurpassos Jul 27, 2026
a690e33
rmv too verbose documentation
arthurpassos Jul 27, 2026
e055b1f
unify
arthurpassos Jul 27, 2026
3848194
vibe coded short term fix
arthurpassos Jul 28, 2026
12f73f0
rmv not necessary comment
arthurpassos Jul 28, 2026
584186f
Revert "vibe coded short term fix"
arthurpassos Jul 28, 2026
b4cca45
check type casting
arthurpassos Jul 28, 2026
d256041
vibe coded fix
arthurpassos Jul 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/en/antalya/partition_export.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,32 @@ The manifest file produced by the commit contains a summary field `clickhouse.ex

The Iceberg manifest files contain statistics about the data. Exporting a merge tree partition is a non ephemeral long running task, in which nodes can be turned off and turned on. This means the stats of individual files need to be persisted somewhere in order to produce the final manifest. This is implemented through sidecars. Each data file exported will contain a "sibling" sidecar file named `<data_file_name>_clickhouse_export_part_sidecar.avro`. ClickHouse does not clean up these files, and they can be safely deleted once the data is comitted.

#### Source partition key compatibility

Because the commit writes a single partition tuple per exported partition, every destination Iceberg partition field must be single-valued across the exported source partition. A source `PARTITION BY` field is accepted when either:

- It structurally matches the destination transform on the same column. The functions with a direct Iceberg equivalent are `identity` (a bare column), `toYearNumSinceEpoch` (`year`), `toMonthNumSinceEpoch` (`month`), `toRelativeDayNum` (`day`), `toRelativeHourNum` (`hour`), `icebergTruncate` (`truncate`), and `icebergBucket` (`bucket`).
- Or the destination transform is proven constant over the exported partition's actual `[min, max]`. This accepts other equivalent or finer keys - for example `PARTITION BY toDate(ts)` or `toYYYYMM(ts)` or `toStartOfHour(ts)` into a destination partitioned by `day(ts)` / `month(ts)` / `hour(ts)`, a bare `Date` column into a `day` transform, or a source that adds extra partition columns on top of the destination's.

The proof uses each part's min/max statistics, so it is data-dependent: a partition whose rows would span more than one destination partition (for example a monthly source partition exported into a daily destination that actually contains several days) is rejected with a `BAD_ARGUMENTS` error at `EXPORT` time.

`bucket` is a hash and is not order-preserving, so it can only be matched structurally: the source must be partitioned by `icebergBucket(N, col)` with the same `N`.

Lossy partition-column casts (allowed via `export_merge_tree_part_allow_lossy_cast`) are supported as long as the cast stays order-preserving over the partition's actual values; a partition whose values cross the destination type's overflow boundary is rejected. A `Nullable` partition column is only accepted through a structural match, because a `NULL` forms its own Iceberg partition.

### On plain object storage exports:

Each MergeTree part will become a separate file with the following name convention: `<table_directory>/<partitioning>/<data_part_name>_<merge_tree_part_checksum>.<format>`. To ensure atomicity, a commit file containing the relative paths of all exported parts is also shipped. A data file should only be considered part of the dataset if a commit file references it. The commit file will be named using the following convention: `<table_directory>/commit_<partition_id>_<transaction_id>`.

#### Source partition key compatibility

The export writes all rows of a part to the single directory computed from the destination `PARTITION BY` on the part's values, so - exactly like the Iceberg gate - each destination partition must be single-valued across the exported source part. A destination partition column is accepted when either:

- The whole source and destination `PARTITION BY` are identical, or the source already partitions by the same expression on that column (this covers a source that adds extra partition columns on top of the destination's, in any order - for example `PARTITION BY (year, country)` into a destination partitioned by `year`).
- Or the destination expression is proven constant over the column's actual `[min, max]` in the part. This is data-dependent and accepts equivalent or finer source keys (for example `PARTITION BY toDate(ts)` into a destination partitioned by `toYYYYMM(ts)` when a part holds a single month). Only provably-monotonic single-argument functions and bare columns are proven this way.

Otherwise the export is rejected with a `BAD_ARGUMENTS` error at `EXPORT` time: this includes a destination that partitions by a column absent from the source partition key, and a source partition whose rows would span more than one destination partition (for example a monthly source partition exported into a daily destination that actually contains several days). A `Nullable` partition column is only accepted through an exact match, because a `NULL` forms its own partition. Partition-column type differences follow the same lossy-cast gate as any other column (`export_merge_tree_part_allow_lossy_cast`).

## Syntax

```sql
Expand Down
12 changes: 12 additions & 0 deletions src/Storages/ExportReplicatedMergeTreePartitionManifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ struct ExportReplicatedMergeTreePartitionManifest
std::optional<UInt64> parquet_row_group_size;
std::optional<UInt64> parquet_row_group_size_bytes;

/// this is a controversial setting. As far as I can infer from the iceberg docs, the transforms are always UTC.
/// this setting allows to specify different timezones. Since it is already implemented, we must respect it.
/// At the same time, we don't allow transforms with timezones, so this is very weird.
std::optional<String> iceberg_partition_timezone;

std::string toJsonString() const
{
Poco::JSON::Object json;
Expand Down Expand Up @@ -290,6 +295,8 @@ struct ExportReplicatedMergeTreePartitionManifest
json.set("parquet_row_group_size", *parquet_row_group_size);
if (parquet_row_group_size_bytes)
json.set("parquet_row_group_size_bytes", *parquet_row_group_size_bytes);
if (iceberg_partition_timezone)
json.set("iceberg_partition_timezone", *iceberg_partition_timezone);
std::ostringstream oss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
oss.exceptions(std::ios::failbit);
Poco::JSON::Stringifier::stringify(json, oss);
Expand Down Expand Up @@ -378,6 +385,11 @@ struct ExportReplicatedMergeTreePartitionManifest
manifest.parquet_row_group_size_bytes = json->getValue<UInt64>("parquet_row_group_size_bytes");
}

if (json->has("iceberg_partition_timezone"))
{
manifest.iceberg_partition_timezone = json->getValue<String>("iceberg_partition_timezone");
}

return manifest;
}
};
Expand Down
Loading
Loading