Skip to content

fix partition pruning for timestamp type - #109764

Merged
Diskein merged 3 commits into
masterfrom
dk-iceberg-datetime64-partition-pruning
Jul 13, 2026
Merged

Diskein merged 3 commits into
masterfrom
dk-iceberg-datetime64-partition-pruning

Conversation

@Diskein

@Diskein Diskein commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed partition pruning returning no rows for Iceberg tables partitioned by a timestamp (DateTime64) column

Version info

  • Merged into: 26.7.1.870 (included in 26.7 and later)
  • Backported to: 26.6.4.55

Without timestamp-micros the value is read back as an Int64 field, and
partition pruning compares it against a Decimal64 constant that never
matches: equality on the partition column silently returned no rows.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2296f4a]

Summary: ✅


AI Review

Summary

This PR updates Iceberg manifest partition typing for timestamp columns and adds a regression test for partition pruning. The new-manifest path looks reasonable, but the backward-compatibility fix for existing manifests written as bare Avro long still does not hold in the current code, so I would not approve it as a complete Bug Fix.

Findings

❌ Blockers

  • [dismissed by author -- https://github.com/fix partition pruning for timestamp type #109764#discussion_r3543687568] src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFileIterator.cpp:298-317 builds partition_key_description from the manifest schema, so legacy manifests that stored timestamp partitions as plain long still get an Int64 partition key. That means the new compatibility branch in src/Storages/ObjectStorage/DataLakes/Iceberg/ManifestFilesPruning.cpp:155-156 can never fire for the old manifests it is annotated to handle. The added test only creates a fresh manifest with timestamp-micros and therefore does not exercise this path either, so existing old tables can still be pruned incorrectly.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: make the legacy bare-long manifest path actually convert to the table's timestamp type during pruning, and add focused coverage that reads a legacy manifest instead of only a newly written one.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 8, 2026
@Diskein
Diskein force-pushed the dk-iceberg-datetime64-partition-pruning branch from 0aede74 to 33be145 Compare July 8, 2026 12:29
@Diskein
Diskein requested a review from murphy-4o July 13, 2026 12:43
@clickhouse-gh

clickhouse-gh Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.90% 85.90% +0.00%
Functions 92.70% 92.70% +0.00%
Branches 78.10% 78.10% +0.00%

Changed lines: Changed C/C++ lines covered: 18/25 (72.00%) · Uncovered code

Full report · Diff report

@Diskein
Diskein added this pull request to the merge queue Jul 13, 2026
Merged via the queue into master with commit 322986b Jul 13, 2026
343 of 344 checks passed
@Diskein
Diskein deleted the dk-iceberg-datetime64-partition-pruning branch July 13, 2026 17:35
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 13, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @Diskein @murphy-4o — a couple of suggestions to make this PR easier for reviewers and the changelog reader.

Description (currently missing):

  • Why: The description is the unmodified PR template (all relationship lines are placeholders); it contains no explanation of the bug or the fix. The regression rationale exists only inside the test file's comment.

  • Suggested addition:

    Explain that ClickHouse previously wrote Iceberg timestamp partition fields as a bare Avro long (no timestamp-micros logical type). On read such a value parses into an Int64 field instead of a DateTime64/Decimal64, so partition pruning compared it against a Decimal64 predicate constant that never matched, over-pruning and silently dropping matching rows. This PR (a) re-wraps such legacy Int64 partition values as DecimalField<Decimal64> using the key's scale before range evaluation, and (b) writes DateTime64 with the timestamp-micros logical type (requiring scale 6).

Ignore this if the current title/body is intentional.

@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 31, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 31, 2026
clickhouse-gh Bot added a commit that referenced this pull request Aug 31, 2026
Backport #109764 to 26.6: fix partition pruning for timestamp type
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ime64-partition-pruning

fix partition pruning for timestamp type
ianton-ru added a commit to Altinity/ClickHouse that referenced this pull request Oct 1, 2026
`getAvroType` required `timestamp-micros` after the ClickHouse#109764 backport, so identity-partitioned `timestamp_ns` writes failed.

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants