Repository navigation
Find a LowCardinality needle equal to the type's default value - #114624
Merged
alexey-milovidov merged 1 commit intoAug 21, 2026
Merged
alexey-milovidov merged 1 commit into
alexey-milovidov merged 1 commit into
Conversation
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes
has,indexOf,countEqual,mapContainsKey,mapContainsValueandMapsubscript returning "not found" for a constantLowCardinalityneedle equal to the element type's default value, such as an emptyStringor a zero number.Description
The problem. A constant needle equal to the element type's default value is never found in an
Array(LowCardinality(T))or aMapwith aLowCardinalitykey. No exception, so aWHEREon such a predicate silently drops rows:Likewise for
0over the numeric types, a NUL-paddedFixedStringand the1970-01-01Date, whilem['']returns''instead of the stored value. Any non-default needle is correct. Reproduces on 26.5 to 26.7.Root cause. A
LowCardinalitydictionary reserves prefix slots for the default and NULL values, andReverseIndexis built withnum_prefix_rows_to_skip, so the reserved slot is never indexed.ColumnUnique::uniqueInsertDatacompensates for that on the write path; the read path had no counterpart.The change.
ColumnUnique::getOrFindValueIndexnow performs the same default-slot match as the write path.ReverseIndexis untouched, so no write behaviour moves.That slot becoming reachable brings two equality details. The lookup casts the constant into the element type without reporting loss, so
UInt64(256)arrived asUInt8(0)and would match the default; that slot now answers only if the element type can represent the constant. And a dictionary can hold-0.0and0.0as separate entries while the shortcut has room for one index, so a zero constant over a float element type is left to the value-comparing path, asindexOfAssumeSortedalready is.The new test covers both call sites. Lookup timing is unchanged.
Overlap with #112953. That open PR declines this same shortcut for every float element type, subsuming the float-zero decline here, and the two conflict textually; whichever merges second should keep the broader decline and drop this one, collapsing the duplicated representability predicate to one copy. Non-float types are independent of it.
Version info
26.7.5.10,26.6.4.7,26.5.8.14,26.3.23.7,25.8.33.6