Repository navigation
Cherry pick #114624 to 26.3: Find a LowCardinality needle equal to the type's default value - #115710
Merged
Merged
Conversation
has, indexOf and countEqual over Array(LowCardinality(T)) compare dictionary indexes, so they first resolve the constant needle to an index. That lookup went through the dictionary's reverse index, which does not contain the reserved prefix slots, so a needle equal to the element type's default value resolved to nothing and every row answered "not found" even when the array held that value. Map(LowCardinality(K), V) key lookups and mapContainsValue share the helper and answered the same way. Match the default slot explicitly in getOrFindValueIndex, which is the read path that the write path (which folds a default element onto that slot) already assumed. Answering from the default slot requires the constant to be representable in the element type, because the cast that brings the needle into the element type narrows without reporting loss: UInt64(256) arrives as UInt8(0) and would otherwise match a UInt8 array's default entry. The guard therefore asks whether the element type can represent the value, by comparing the constant against its own cast image in the type the two types compare through. A round trip back into the needle's type would answer a different and wrong question for a pair that compares through a common type rather than by narrowing: Enum8 -> FixedString pads on the way out and rejects that padding on the way back, so a value the element type holds exactly would read as lost and a present element would be reported missing. Pairs with no common type only compare as numbers, which is the narrowing case, so there the needle's own type is where they meet. A float zero is left to the value-comparing path: -0.0 and 0.0 are equal but occupy two byte-distinct dictionary entries, and one index cannot denote both. The needle types this decline names are the ones that can reach the site. IPv4 is also admitted beside a float element, but an IPv4 needle throws NOT_IMPLEMENTED in the cast before the lookup is reached, unchanged by this commit.
…alue-needle Find a LowCardinality needle equal to the type's default value
Reconcile the cherry-pick of #114624 with `26.3`. `26.3` does not have `src/Functions/LowCardinalityExecutionHelpers.h` - the constant-needle dictionary lookup still lives inline in `FunctionArrayIndex::executeArrayLowCardinality`. The new header was therefore dropped and its two helpers, `isConstantCastDecline` and `targetTypeRepresentsValue`, were placed in a `ArrayIndexLowCardinalityHelpers` namespace in `src/Functions/array/arrayIndex.h`, with the `find_in_dictionary` guard applied to the inline lookup. Original pull-request: #114624
alexey-milovidov
added a commit
that referenced
this pull request
Aug 22, 2026
Resolve the `modify/delete` conflict on `src/Functions/LowCardinalityExecutionHelpers.h`: that header does not exist on `25.8`, where the constant-needle dictionary lookup still lives inline in `FunctionArrayIndex::executeArrayLowCardinality` in `src/Functions/array/arrayIndex.h`. Drop the header and port `isConstantCastDecline` and `targetTypeRepresentsValue` into a new `ArrayIndexLowCardinalityHelpers` namespace in `arrayIndex.h`, and guard the inline lookup with `find_in_dictionary`, matching the resolutions of the sibling backports #115710 (26.3) and #115711 (26.5).
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 #114624
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.
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