Repository navigation
Do not treat a NULL inside a tuple key as a NULL key - #119081
Conversation
`extractNestedColumnsAndNullMap` folded the null maps of the elements of a `Nullable(Tuple(Nullable(T), ...))` key into the key's null map, so a row whose tuple merely contains a NULL was a NULL key. The hash-family joins dropped such a row, while the merge algorithms compare the nested tuples and kept it, so the result of a join depended on `join_algorithm`; wrapping a key that is never NULL in `toNullable` was enough to change it. Only the top level says whether the key of a row is NULL. The NULLs of the elements are part of the key and are compared as any other value, exactly as they are for a `Tuple(Nullable(T), ...)` that is not wrapped in `Nullable`. Closes: #118816
|
Workflow [PR], commit [ac653e2] Summary: ✅
AI ReviewSummaryThis PR fixes the hash-family join handling of Findings❌ Blockers
Final Verdict❌ Changes requested. LLVM Coverage ReportMeasured on commit ac653e2.
Changed lines: Changed C/C++ lines covered: 2/2 (100.00%) · Uncovered code |
| * The NULLs of the elements are part of the key and are compared as any other value, | ||
| * exactly as they are for a `Tuple(Nullable(T), ...)` that is not wrapped in `Nullable`. | ||
| */ | ||
| column = &column_nullable->getNestedColumn(); |
There was a problem hiding this comment.
extractNestedColumnsAndNullMap is also the null-key filter for subquery-backed IN, not just joins. Set still documents the transform_null_in = 0 contract as “ignore any tuples with at least one NULL element” (src/Interpreters/Set.h:119), and the existing non-subquery coverage keeps that behavior for both Tuple(Nullable(...)) and Nullable(Tuple(Nullable(...))) (tests/queries/0_stateless/04234_non_constant_rhs_in.reference:84-90).
With this change, only the subquery/table-backed IN path flips to 1 for the wrapped tuple shape, while literal and row-wise IN still return 0, so we trade one inconsistency for another. I think the relaxed null-map handling needs to stay join-only, or Set semantics need to be changed consistently across all IN implementations in a broader compatibility change.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
For a
Nullable(Tuple(Nullable(T)))join key that is never NULL at the top level, the hash-family algorithms treated any row whose tuple contains a NULL element as a NULL key and dropped it, while the merge algorithms compare the nested tuples and kept it. The same query on the same data returned a different row count depending only onjoin_algorithm(hash/parallel_hash/grace_hash= 1,full_sorting_merge/partial_merge= 2), and wrapping a key intoNullable- a value-wise no-op there - was enough to change the result.extractNestedColumnsAndNullMapfolded the null maps of the tuple's elements into the key's null map. Only the top level says whether the key of a row is NULL; the NULLs of the elements are part of the key and are compared as any other value, exactly as they are for aTuple(Nullable(T))that is not wrapped inNullable. A row whose key really is NULL still joins nothing, and it is not the same key as a tuple of NULLs.The same extraction is used by
INwith a subquery, which had the mirror defect: such a row matched nothing there either.Closes: #118816
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed the hash-family join algorithms treating a non-NULL
Nullable(Tuple(...))key that contains a NULL element as a NULL key, which made the result of a join depend on thejoin_algorithmsetting.INwith a subquery over such a key was affected in the same way.Workflow [PR]
Sync PR [sync-upstream/pr/119081]
Version info
26.9.1.1101(included in26.9and later)