Skip to content

Cherry pick #119302 to 26.7: Revert "Revert "Proper partition pruning with dates"" - #121352

Merged
robot-ch-test-poll4 merged 12 commits into
backport/26.7/119302from
cherrypick/26.7/119302
Sep 26, 2026
Merged

robot-ch-test-poll4 merged 12 commits into
backport/26.7/119302from
cherrypick/26.7/119302

Conversation

@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

Original pull-request #119302

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 11 commits September 10, 2026 19:26
…it is

An Iceberg partition field summary keeps its bounds in the single-value
serialization of the partition field's own type, and for the `day`, `month`,
`year` and `hour` transforms that type is a signed `int` counting units from
1970. ClickHouse models those transforms in the partition key with
`toRelativeDayNum`, `toMonthNumSinceEpoch`, `toYearNumSinceEpoch` and
`toRelativeHourNum`, whose result types are unsigned, so
`ManifestListPruner::canBePruned` read a bound from before 1970 as a huge
unsigned number. For a manifest that spans 1969 and 2024 the lower bound then
came out above the upper bound, and `KeyCondition::checkInRange` hit
`chassert(key_order.compareTuples(left_keys, right_keys, used_key_size) <= 0)`,
which aborts a build with assertions.

That is why
`test_storage_iceberg_with_spark/test_partition_pruning_with_functions.py::test_partition_pruning_with_functions_before_epoch`
started failing on master in `Integration tests (amd_tsan, 3/6)` and
`Integration tests (amd_msan, 8/8)`: the `toDate32` monotonicity that
#118606 gave a `Nullable` column
made the filter of that test reach the pruner.

A bound of an unsigned key column is now read as the signed number Iceberg
wrote, and a negative one leaves the whole field unknown: the ClickHouse
functions that stand for those transforms cannot return a negative number -
they map every point before 1970 to zero - so nothing about the key's value
space follows from such a bound and no range of it may be pruned on.

A pair of bounds that comes out inverted now drops the field with a warning
instead of being pruned on, the same as `ManifestFileIterator` already does
for the min/max bounds of a data file.

Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=290309210c5b2f0e01c13fd0fbae6577fb5cb9cd&name_0=MasterCI&name_1=Integration%20tests%20%28amd_tsan%2C%203%2F6%29

Related: #118606
Related: #116499
Related: #116604

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The `day`, `month` and `year` transforms of the Iceberg specification count from
1970-01-01 with no timezone applied, so inverting one of their values back into a
range of the source column must use the `UTC` calendar and must ignore the
timezone declared on the `DateTime64` that an Iceberg `timestamp` is read into.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…n shape

`EXPLAIN indexes = 1` prints two lines that contain `Granules:`: the
`Parts: 1 | Granules: 2` summary of the `ReadFromMergeTree` step and the
`Granules: 2/10` of the primary key index analysis. The test grepped for both
and stripped the indentation with `trimLeft`, which made it depend on the shape
of the plan around them:

- with `make_distributed_plan = 1` the step summary is not printed at all, so the
  test lost three lines;
- with parallel replicas the whole subtree is printed under a `│` prefix, which
  `trimLeft` does not strip, so all six lines came out prefixed.

The granule count is now read with `extract(explain, 'Granules: \d+/\d+')`, which
picks the index analysis line out of any indentation or prefix and does not match
the step summary at all. That is also the line the test is about: it says the
index analysis narrowed ten granules down to two.

Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119302&sha=323a1976ae947f4c28bca9cea92d08d6913e4f86&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29

Related: #118606

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…6-iceberg_partition_pruning_todate

Revert "Revert "Proper partition pruning with dates""
@robot-ch-test-poll3 robot-ch-test-poll3 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Sep 21, 2026
@robot-clickhouse

Copy link
Copy Markdown
Member

Dear @alexey-milovidov, @scanhex12, this cherry-pick PR has not been updated for 3d0h2m41s. Please resolve the conflicts to backport #119302, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

Resolve the conflicts of the cherry-pick of #119302 to 26.7.

26.7 had the original backport of #118606 merged and then reverted
(#119253, #119431), so the resolution reapplies that 26.7 backport
(reverts `d10ac36aeab8`) and then applies the follow-up commits of #119302
on top of it.

26.7 has no `ManifestListPruning.cpp` (manifest-list level pruning is not
on this branch), so the hunks of #119302 for that file are dropped, and
with them the `deserializeDecimalFromBinaryRepr` refactoring of
`213367fdc76a`, which only existed to share the decimal decoding with that
file; 26.7 keeps its own `decodePartitionDecimalByType`. The
`ManifestFilesPruning.cpp` interval helpers, the `05054` test and the
`test_partition_pruning_with_functions.py` integration test match master.

Related: #119302

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Resolved the conflicts in 7f95b05 (merge of backport/26.7/119302). 26.7 had the earlier backport of #118606 merged and then reverted (#119253, #119431), so the resolution reapplies that 26.7 backport and then applies the follow-up commits of #119302 on top. 26.7 has no ManifestListPruning.cpp, so the hunks for that file are dropped, along with the deserializeDecimalFromBinaryRepr refactoring in 213367fdc76a, which only existed to share code with that file. The ManifestFilesPruning.cpp interval helpers and both tests (05054 and test_partition_pruning_with_functions.py) match master. The diff against the base touches only the 7 PR files. ManifestFilesPruning.cpp and FunctionsConversion.cpp pass a syntax-only compile against the 26.7 sources. Neither a full build nor any test was run locally.

@robot-ch-test-poll4
robot-ch-test-poll4 merged commit a9e72b9 into backport/26.7/119302 Sep 26, 2026
1 check passed
@robot-ch-test-poll4
robot-ch-test-poll4 deleted the cherrypick/26.7/119302 branch September 26, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants