Skip to content

Cherry pick #128086 to 26.10: Fix missing rows in EmbeddedRocksDB, KeeperMap and Redis key lookups for a float compared with a Decimal key - #132977

Merged
robot-clickhouse merged 6 commits into
backport/26.10/128086from
cherrypick/26.10/128086
Nov 19, 2026
Merged

robot-clickhouse merged 6 commits into
backport/26.10/128086from
cherrypick/26.10/128086

Conversation

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Original pull-request #128086

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

groeneai and others added 5 commits October 28, 2026 17:27
`=` compares a float with a `Decimal`, `DateTime64` or `Time64` value as
`Float64`, and `IN` compares the key cast to the set element type, so a
float can equal keys other than its cast to the key type. `getFilterKeys`
cast the float into the key type, which truncates (`19.99` becomes
`19.98`), and looked up only that key, so `EmbeddedRocksDB`, `KeeperMap`
and `Redis` returned no rows for `k = 19.99` over a `Decimal(10, 2)` key
holding `19.99`, and `ALTER DELETE` with that condition deleted nothing.
At a high scale several stored values share one float image.

Reuse `floatValuesMissKeyValues`, which the MergeTree key analysis uses
for the same comparison, to decline the key filter (full scan, the
condition is still applied) for `=`, for `IN` sets and per element of a
tuple `=` / `IN` over a composite key. An exact float over a `Decimal32`
or `Decimal64` key keeps the lookup.

A constant node of an `ActionsDAG` holds a `ColumnConst` of 0 rows, and
the helper walks the rows of its column, so the constant is passed as a
1-row column (`cloneResized(1)`), the value `getField()` reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A scalar subquery returns a `Nullable(Tuple(...))` constant, so the tuple
`=` branch did not see a `ColumnTuple` and checked the whole tuple against
every key column: any float element declined the lookup, also for an exact
`(a, b) = (SELECT (12.5, 1))` over a `Decimal` key and for a composite key
with no float compared with a `Decimal`. Unwrap one outer `Nullable` of
the column and the type before the per-element check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tuple IN branch builds each lookup key from a `Field`, and a `Field`
holds a `Float32` as `Float64`, so `tryConvertFieldToType` scales the
widened value in `Float64`. `floatValuesMissKeyValues` cast the original
`Float32` column instead, in `Float32` arithmetic. The two can disagree:
`toFloat32(0.29)` is `0.28999999165534973`; times 100 in `Float32` that
rounds to 29 (key `0.29`, which the check proves is the only match),
while in `Float64` it is `28.999999165534973` and truncates to 28, so the
lookup probed `0.28` and `(a, b) IN (SELECT toFloat32(0.29), 1)` missed
the stored `(0.29, 1)` (also inside `Nullable`/`LowCardinality`).

Widen a `Float32` set column to `Float64` before the check, so it proves
the key the lookup actually builds. The comparison type stays the set
column's own type. A lookup whose `Float64` cast is exact is kept
(`toFloat32(12.5)` still reads `GetKeys`).

The `=` branches compare in `Float64`. An exhaustive search over the
keys the check can accept there (every `Decimal32`/`Decimal64` key at
scales 1-18 that a `Float32` product can produce exactly) found none
where the two casts disagree, so they stay as they are. The
single-column IN branch already converts with the same typed cast as
the check.

Found by the automated review on #128086.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oat-constant

Fix missing rows in `EmbeddedRocksDB`, `KeeperMap` and `Redis` key lookups for a float compared with a `Decimal` key
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 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 pr-bugfix Pull request with bugfix, not backported by default labels Nov 19, 2026
@robot-clickhouse

Copy link
Copy Markdown
Member

The 26.10 branch moved since this cherry-pick was created (now at 49c9108). Re-tried the merge against it and it applies cleanly, so the bot is proceeding without manual resolution.

@robot-clickhouse
robot-clickhouse merged commit 3d8552e into backport/26.10/128086 Nov 19, 2026
1 check passed
@robot-clickhouse
robot-clickhouse deleted the cherrypick/26.10/128086 branch November 19, 2026 16:24
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-bugfix Pull request with bugfix, not backported by default 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.

4 participants