Skip to content

Cherry pick #119302 to 26.8: Revert "Revert "Proper partition pruning with dates"" - #121353

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

robot-ch-test-poll2 merged 12 commits into
backport/26.8/119302from
cherrypick/26.8/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 3d0h2m11s. 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 cherry-pick of #119302
onto 26.8. The resolution starts from the earlier 26.8 backport of
#118606 (ff6b795), which
already adapted `FunctionsConversion.h` and `ManifestFilesPruning.cpp` to 26.8,
and then applies the follow-up commits of the reland that touch those files
(323a197, bad2875, 9bb3a34) plus the updated tests.

Dropped, because 26.8 does not have the code they modify:
- `ManifestListPruning.cpp` (manifest-list pruning is not on 26.8), which carried
  the pre-1970 summary-bound fix of 039006e;
- the `deserializeDecimalFromBinaryRepr` helper of 213367f in
  `IcebergFieldParseHelpers`: that commit only deduplicated the decimal decoding,
  26.8 keeps the equivalent local `decodePartitionDecimal` in
  `ManifestFilesPruning.cpp`;
- the `getPreimage` of `ToDateMonotonicity`, which is master-only.

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

Copy link
Copy Markdown
Member

🕵 Resolved the conflicts in ef53542; the PR is now mergeable.

  • Started from the earlier 26.8 backport of Proper partition pruning with dates #118606 (ff6b795), which had already adapted FunctionsConversion.h and ManifestFilesPruning.cpp to 26.8. On top of that I applied the reland's follow-up commits to ManifestFilesPruning.cpp (323a197, bad2875, 9bb3a34) and took the updated 05054 and test_partition_pruning_with_functions.py tests.
  • Dropped, because 26.8 doesn't have the code they change:
    • ManifestListPruning.cpp: manifest-list pruning isn't on 26.8. This also drops the pre-1970 summary-bound fix from 039006e; the chassert it guarded against is in that pruner.
    • The deserializeDecimalFromBinaryRepr helper refactor (213367f): it only removed duplicate decimal-decoding code. 26.8 keeps the equivalent local decodePartitionDecimal.
    • The master-only ToDateMonotonicity::getPreimage.
  • The diff against backport/26.8/119302 is exactly the 5 files of the original PR. ManifestFilesPruning.cpp and FunctionsConversion_impl00.cpp compile on 26.8. I did not run the tests locally.
  • Please check test_partition_pruning_with_functions_before_epoch_separate_commits on the backport CI. Its pruned-file counts were written for master, where whole manifests are also pruned at the manifest-list level, so the counts may differ on 26.8.

@robot-ch-test-poll2
robot-ch-test-poll2 merged commit 665fe01 into backport/26.8/119302 Sep 26, 2026
1 check passed
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/26.8/119302 branch September 26, 2026 04:07
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