Repository navigation
Fix SQL columns for input with a named record type - #7603
Merged
Merged
Conversation
The SQL table for input whose fused type is a union with more than one
record type took its columns from only the first record type. The
fuser keeps named types apart, so this happens whenever the input has a
named record type and another record type, e.g., the fused type of
foo={a:int64} and {b:int64} is fusion(foo|{b:int64}). SELECT * then
dropped a column, and a reference to it was a compile error. Fuse the
union's record types instead, and update the test from #7548, which
expected the dropped column.
Fixes #7468
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mccanne
approved these changes
Nov 4, 2026
mccanne
left a comment
Collaborator
There was a problem hiding this comment.
This stuff is a bit fragile, but step in the right direction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7468
When the input to a SQL query has a named record type and another record type, the table's columns came from only one of the record types. #7548 fixed the
errorvalues in the original repro, butSELECT *still dropped a column, and a reference to the dropped column was a compile error.With this PR, the table has the columns of both record types:
(Previously
{a:1}/{a:null}, and"b" is not a column or table.)The fuser keeps named types apart, so the fused type of this input is
fusion(foo|{b:int64}), a union with two record types, andrecordOf()incompiler/semantic/schema.goused only the first. This PR:recordOf(), so the columns are the same as for the input without the named typeSELECT band for two named record types (where tip kept onlyb)The fix covers every way SQL gets its input: a file, a pipe into
SELECT, a subquery, or a CTE. With-dynamic, column references likeSELECT balready worked. Because such a table now has all its columns, a join can newly report an unqualified column as ambiguous, as it already did for the same input without the named type.The patch was drafted with Claude Code. I reviewed and tested it, and ran it through Claude Code's
/code-review high.