Repository navigation
Cherry pick #114624 to 25.8: Find a LowCardinality needle equal to the type's default value - #115709
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
|
All three conflicting cherry-picks in this wave (25.8, 26.3, 26.5) fail for one shared reason: One correction to my description on #114624, which said the bug reproduces on 26.5 to 26.7. It reproduces on all five active release branches. The merged test is self-oracling, each row printing the So closing the older three leaves the silent wrong result in 25.8, 26.3 and 26.5. I am not hand-resolving these, per the standing no-manual-backport rule. Flagging the measurement so the disposition is an informed one. |
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).
|
🕵 Resolved the conflict: Same resolution as the sibling backports #115710 (26.3) and #115711 (26.5). Verified with a single-TU |
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