Repository navigation
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
Conversation
`=` 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]>
…ecimal-float-constant
…oat-constant Fix missing rows in `EmbeddedRocksDB`, `KeeperMap` and `Redis` key lookups for a float compared with a `Decimal` key
Member
|
The |
robot-clickhouse
force-pushed
the
backport/26.10/128086
branch
from
November 19, 2026 16:24
ac30011 to
01fa34d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-picklocally.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:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job