Skip to content

Cherry pick #114624 to 26.5: Find a LowCardinality needle equal to the type's default value - #115711

Merged
robot-ch-test-poll merged 3 commits into
backport/26.5/114624from
cherrypick/26.5/114624
Aug 22, 2026
Merged

robot-ch-test-poll merged 3 commits into
backport/26.5/114624from
cherrypick/26.5/114624

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

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-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.

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 2 commits August 13, 2026 10:41
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
@robot-ch-test-poll4 robot-ch-test-poll4 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 Aug 21, 2026
`26.5` does not have `src/Functions/LowCardinalityExecutionHelpers.h`: the
constant-needle dictionary lookup still lives inline in
`FunctionArrayIndex::executeArrayLowCardinality`. Resolve the modify/delete
conflict by dropping the new header and porting `isConstantCastDecline` and
`targetTypeRepresentsValue` into an `ArrayIndexLowCardinalityHelpers`
namespace in `src/Functions/array/arrayIndex.h`, together with the
`find_in_dictionary` guard on the inline lookup.
@robot-ch-test-poll
robot-ch-test-poll merged commit 659b71d into backport/26.5/114624 Aug 22, 2026
@robot-ch-test-poll
robot-ch-test-poll deleted the cherrypick/26.5/114624 branch August 22, 2026 13:31
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).
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