Antalya 26.3: Fix empty partition_key and sorting_key in system.table…#1874
Antalya 26.3: Fix empty partition_key and sorting_key in system.table…#1874il9ue wants to merge 1 commit into
Conversation
…s for Iceberg tables without data snapshots Changelog category: Bug Fix Changelog entry: Fixed `system.tables.partition_key` and `system.tables.sorting_key` returning empty strings for Iceberg tables that have no data snapshot, including all empty tables and (more frequently) tables accessed via the Glue catalog. The snapshot-existence gate in IcebergMetadata::partitionKey() / sortingKey() was semantically wrong: partition spec and sort order are table-level properties recorded at the top level of the Iceberg metadata file (`default-spec-id`, `default-sort-order-id`) and exist independently of whether any data snapshot has been written. Also adds a defensive guard in getSortingKeyDescriptionFromMetadata against Iceberg V1 metadata files missing `sort-orders`, which becomes reachable for empty tables after this fix. Closes #1235.
Status update on the
|
|
AI audit note: This review comment was generated by AI (gpt-5.3-codex). Audit update for PR #1874: Confirmed defects: No confirmed defects in reviewed scope. Coverage summary:
|
PR #1874 CI TriagePR: Antalya 26.3: Fix empty partition_key and sorting_key in system.tables for Iceberg tables without data snapshots Changed files:
Summary
Verdict: 1 failure is caused by this PR. 5 are infrastructure issues unrelated to the code change. Failure Detail1.
|
| Line | Current assertion | Correct assertion after fix |
|---|---|---|
| 56 | assert partition_key == "" |
assert partition_key == "name" |
| 57 | assert sorting_key == "" |
assert sorting_key == "name asc" |
| 74 | assert partition_key == "" |
assert partition_key == "name" |
The step description at line 47 ("check partition_key and sorting_key are not set in system.tables before first insert") should also be updated to reflect the correct new expectation.
Note: The other failures in
iceberg_2(predicate push-down S3 request counts, partition pruning counts) are all classified as Known Fails (XFail) in the report and are pre-existing issues unrelated to this PR.
2. Regression aarch64 tiered_storage_minio — Infrastructure issue (runner teardown hang)
Status summary: Module errored, but the inner feature tiered storage/with minio completed OK (1h 33m, 95.6% pass).
Error:
ExpectTimeoutError: Timeout 1000.000s for '[#\$] '
at: bash(f"cd {self.docker_compose_project_dir}", timeout=1000)
The bash shell became completely unresponsive during cluster teardown — a Docker/resource hang on the aarch64 runner. No test assertions were affected; all 90 scenarios passed, and the 4 XFail scenarios (attach or replace partition different policies, double move while select, manual move with downtime) are pre-existing known failures with tracked Jira issues.
Caused by PR: No
3. Regression release tiered_storage_local — Infrastructure issue (runner teardown hang)
Status summary: Module errored, but the inner feature tiered storage/normal completed OK (1h 37m, 96% pass).
Error: Same ExpectTimeoutError: Timeout 1000.000s during bash teardown as above, on the x86_64 runner this time.
All 90 scenarios passed; the 4 XFail scenarios are the same pre-existing known failures as in the minio variant.
Caused by PR: No
4. Regression aarch64 s3_gcs_2 — Infrastructure issue (runner teardown hang)
Error: ExpectTimeoutError: Timeout 1000.000s for '[#\$] ' during Cluster.__exit__ teardown — same pattern as tiered_storage failures above. The bash shell hung on the aarch64 runner.
All 39 OK scenarios passed. The 31 XFail scenarios are pre-existing known failures. No actual test assertions failed.
Caused by PR: No
5. Regression aarch64 clickhouse_keeper_failover — Infrastructure issue (runner setup timeout)
Error: ExpectTimeoutError: Timeout 10.000s while copying the binary file at cluster setup (bash(f"cp {self.binary_path} {new_path}")). The aarch64 runner was so resource-starved that even a cp command timed out.
The one test scenario (dynamic failover) that was attempted is marked XFail (known issue). The x86_64 version of the same job ran successfully (all 3 scenarios XFail as expected, module OK).
Caused by PR: No
6. RegressionTestsRelease / Common (disk_level_encryption) — Infrastructure issue (likely)
Job: https://github.com/Altinity/ClickHouse/actions/runs/27000320264/job/79688545408
Duration: 30m 4s, failed
No S3 report was uploaded for this job (404 on expected report path; no disk_level_encryption/ directory in the artifact listing). This indicates the test cluster setup failed before any tests ran, or results were never uploaded. The job completed at 2026-06-05T08:37:42Z.
Disk-level encryption tests are completely orthogonal to the PR's Iceberg changes (IcebergMetadata.cpp / Utils.cpp). There is no plausible code path connecting them.
Caused by PR: No
Infrastructure Pattern
The aarch64 runner (and to a lesser extent the x86_64 runner) exhibited widespread Docker hang symptoms during this CI run — 3 of the 4 aarch64 jobs errored with Timeout 1000.000s for '[#\$] ' in bash teardown, and one errored with a 10s cp timeout at setup. This is consistent with runner resource exhaustion (OOM, I/O saturation, or Docker daemon instability) on that particular run date (Jun 05, 2026), not with any code introduced by this PR.
Recommendations
-
Fix the regression test in
iceberg/tests/iceberg_table_engine/system_tables_partition_sorting_keys.py:- Lines 55–57: change assertions from
== ""to the new expected values ("name"/"name asc") and update the step description. - Line 72–74: change
assert partition_key == ""toassert partition_key == "name". - The test was documenting the old bug; it should now verify the corrected behavior.
- Lines 55–57: change assertions from
-
Re-run infrastructure failures —
tiered_storage_minio,tiered_storage_local,s3_gcs_2,clickhouse_keeper_failover,disk_level_encryptionwill all pass on a healthy runner. -
No code changes needed to the production fix itself — only the test expectations need updating.
|
Updated the regression test Currently rerunning failed jobs... |
Closes #1235. Supersedes #1819 — reopened from a branch in the Altinity/ClickHouse repo so CI exposes direct .deb package URLs for clickhouse-regression (fork PRs only produce GitHub Actions artifact zips).
Summary
SELECT partition_key, sorting_key FROM system.tablesreturned empty strings for Iceberg tables that had no data snapshot. Reliably observable via the Glue catalog (itsmetadata_locationmore frequently points at a snapshot-free metadata file), but also reproduced for any empty Iceberg table regardless of catalog (REST, Glue, or directIcebergS3).Root cause
IcebergMetadata::partitionKey()andIcebergMetadata::sortingKey()(#959, refined in #1026, ported to 25.8 in #1095) gated their work on the existence of a data snapshot:This is semantically wrong. Partition spec and sort order are table-level properties recorded at the top level of the Iceberg metadata file (
default-spec-id,default-sort-order-id,partition-specs,sort-orders) and exist independently of whether any data snapshot has been written.getState()populatesactual_table_state_snapshot(schema_id,metadata_file_path,metadata_version) regardless of snapshot existence; onlysnapshot_idisstd::nullopt, and that field is never read bygetPartitionKey()/getSortingKey(). The gate was dead-gating valid data; the fix removes it.Change list
src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp— removed theif (!actual_data_snapshot)early return inpartitionKey()andsortingKey().src/Storages/ObjectStorage/DataLakes/Iceberg/Utils.cpp—getSortingKeyDescriptionFromMetadata()now guards onhas(sort-orders)/has(default-sort-order-id). Pre-existing null-deref, previously unreachable behind the snapshot gate; after removing the gate, empty Iceberg V1 tables withoutsort-orders(optional in V1, required from V2) would hit it. Mirrors the shape ingetSortingKeyDisplayStringFromMetadata.No header changes. No
StorageSystemTables.cppchanges — the #1210 (Glue segfault) null/exception guards remain untouched.Behavior preservation
NULLS FIRST/NULLS LAST).getPartitionKeyStringFromMetadataalready guards on missingpartition-specs).StorageSystemTables.cppremain in place.Out of scope
Glue's
metadata_locationpointer can lag schema-evolution events, which could surface a stale spec. Orthogonal to the snapshot gate; not addressed here.Test plan
New regression test reproduces the root cause without a catalog mock: creates an Iceberg table with a non-trivial partition spec and sort order, asserts
system.tables.partition_key/sorting_keyare non-empty before any insert. Existingtest_system_tables_partition_sorting_keyscontinues to pass with byte-identical output.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed
system.tables.partition_keyandsystem.tables.sorting_keyreturning empty strings for Iceberg tables that have no data snapshot, including all empty tables and (more frequently) tables accessed via the Glue catalog. Also added a defensive guard against Iceberg V1 metadata files missingsort-orders.Documentation entry for user-facing changes
Not required — bug fix to existing
system.tablescolumns; no new user-facing surface.