fix(query): align full outer USING nullability#19616
fix(query): align full outer USING nullability#19616sundy-li wants to merge 2 commits intodatabendlabs:mainfrom
Conversation
| .nth(idx) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| if matches!(join_op, JoinOperator::FullOuter) |
There was a problem hiding this comment.
For USING, unqualified name resolution keeps only the one binding whose visibility stays visible (see BindContext::match_column_binding), so this branch is still making x resolve to a single input column. For FULL OUTER JOIN, that is not the merged USING semantics: SELECT x FROM (SELECT 1 AS x) a FULL OUTER JOIN (SELECT 2 AS x) b USING (x) should surface 1, 2, but the surviving left-side binding yields 1, NULL on the right-only row. This patch aligns the schema with the current nullable left-column behavior instead of fixing the merged-key behavior. The fix needs to produce a coalesced visible USING expression (or equivalent) and the regression test should assert row values, not only the inferred type.
🤖 CI Job Analysis
📊 Summary
❌ NO RETRY NEEDEDAll failures appear to be code/test issues requiring manual fixes. 🔍 Job Details
🤖 AboutAutomated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed). |
| .add_derived_column(join_key_name.clone(), (*left_column.data_type).clone()); | ||
| let coalesced_scalar = ScalarExpr::FunctionCall(FunctionCall { | ||
| span: None, | ||
| func_name: "coalesce".to_string(), |
There was a problem hiding this comment.
FunctionCall { func_name: "coalesce" } is not executable in this planner path. CI is failing with UnknownFunction: function coalesce does not exist, and the sqllogic failures point directly at NATURAL/FULL OUTER JOIN queries after this rewrite. Please build this expression through the normal type-check / function-resolution path (or use the internal scalar form that execution already understands) instead of hard-coding a raw FunctionCall here.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
USING/NATURALjoin key as nullable forFULL OUTER JOINso the planned result schema matches the hash-join output schema.FULL OUTER JOIN ... USINGquery.Changes
resolve_using()in the join binder to preserve nullable result metadata for visibleFULL OUTER JOINkeys.build_result_projection()to returnErrorCode::Internalinstead of panicking on schema mismatches.INT64output fromFULL OUTER JOIN ... USING.Tests
Attempted:
cargo test -p databend-query --test it sql::schema::test_full_outer_join_using_reports_nullable_result_schema -- --exactBlocked in this environment by missing toolchain dependencies:
clang/moldlinker configuration from.cargo/config.tomlprotocrequired bydatabend-meta-typesanddatabend-meta-protobuild scriptsType of change
Fixes #19568
This change is