Repository navigation
Fix mixed JOIN ON condition over a dictionary with join_use_nulls - #113933
alexey-milovidov wants to merge 3 commits into
Conversation
When a prepared join storage (a dictionary lookup) with `join_use_nulls` falls back from a direct join to a hash join because of a mixed (cross-side non-equi) `ON` condition, the plan converts the right columns of the outer join to `Nullable` in place, without keeping the raw input column the mixed condition was built against. The stored right block then holds `Nullable(T)` under the name for which `buildAdditionalFilter` creates a plain `T` column, and `insertFrom` read the column through the wrong type: wrong results in release builds (the residual matched arbitrary rows) and a failed type-equality `chassert` in debug stress runs (STID 2508-2e0c). Unwrap the `Nullable` when filling the filter's right-side columns; the stored rows are real right-side rows, never NULL-extended, so the unwrap is exact, and a genuine NULL now throws a `LOGICAL_ERROR` exception instead of being misread. Closes: #113931 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [fceb4cb] Summary: ❌
AI ReviewSummaryThis PR fixes wrong results for mixed Missing context / blind spots
Final Verdict✅ No new blockers or majors. The current head fixes the earlier LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 16/21 (76.19%) · Uncovered code |
…ition-dict-join-use-nulls
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units37 translation units recompiled, 491 s compile time in total, 37 of them have a recent master baseline. |
…nal join filter like plain `Nullable` `JoinUtils::tryConvertColumnToNullable` wraps a right-side `LowCardinality(T)` column as `LowCardinality(Nullable(T))`, which reports `isNullable() == false` and exposes the nullability only through `nestedIsNullable`. The previous branch handled only plain `ColumnNullable`, so such a column fell through to `insertFrom`, where `ColumnLowCardinality::insertFrom` converts a genuine NULL dictionary entry into the nested default value instead of rejecting it. Detect the nested-nullable source, throw a logical error on a genuine NULL, and insert the non-NULL value through a `Field` round-trip on this cold path. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 Superseded by #113534, which merged into Both pull requests fix the same defect (issue #113931) at two different layers, and they are semantically incompatible: #113534 fixes it at the plan level ( Test coverage is not lost: the merged Thanks @groeneai for the measured analysis that established the two pull requests were the same defect at two layers. |
With
join_use_nulls = 1, a mixed (cross-side non-equi)ONcondition over a dictionary right side returned wrong results in release builds and failed a type-equalitychassertin debug builds — the dominant stress-test failureSTID: 2508-2e0c, hitting master and dozens of pull requests daily since 2026-08-04.Since #112831, such a join correctly declines the direct-join lookup and falls back to a hash join. But for a prepared join storage the plan converts the right columns of the outer join to
Nullablein place, without keeping the raw input column the mixed condition was built against (a plain table keeps bothtoNullable(__table2.a)and the raw__table2.a).buildAdditionalFilterbinds the filter's required columns to the stored right block by name, creates the column with the filter's plain type, andinsertFromthen read aNullablecolumn through a non-Nullableone: garbage filter input in release (SELECT count(), sum(d.a) FROM t3 LEFT ANY JOIN dict AS d ON (t3.key = d.key) AND (t3.a * 10 < d.a) SETTINGS join_use_nulls = 1returned4, 80instead of4, 60), a failedchassertinIColumn::assertTypeEqualityin debug.The fix unwraps the
Nullablewhen filling the filter's right-side columns. The stored rows are real right-side rows, never NULL-extended, so the unwrap is exact; a genuine NULL now throws aLOGICAL_ERRORexception instead of being misread.Added
04821_mixed_join_condition_dictionary_join_use_nullscoveringLEFT ANY/LEFT/INNER/SEMI/ANTIwithhashandparallel_hash, and verifying unmatched rows are NULL-extended. The existing04667_mixed_join_condition_algorithm_selectionstill passes.Closes: #113931
Related: #112831
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix wrong results (and a logical-error exception in debug builds) for a mixed
JOIN ONcondition (equality plus a cross-side inequality) over a dictionary whenjoin_use_nullsis enabled.