Skip to content

Conversation

@mccanne
Copy link
Collaborator

@mccanne mccanne commented Oct 14, 2025

This commit adds a pipe schema concept to the semantic pass so that column references can be properly resolved for pipe subqueries embedded as SQL table expressions. It calls the type checker to compute the super.Type of the pipe subquery and uses that type to infer the available columns for SQL expressions.

This logic will need to be extended when we add support for correlated subqueries, likely requiring type tracking to be more tightly integrated with the translator pass (e.g., tracking the type all the way from the input to the query instead of locally analyzing the pipe subquery).

This commit adds a pipe schema concept to the semantic pass so
that column references can be properly resolved for pipe subqueries
embedded as SQL table expressions.  It calls the type checker to
compute the super.Type of the pipe subquery and uses that type
to infer the available columns for SQL expressions.

This logic will need to be extended when we add support for correlated
subqueries, likely requiring type tracking to be more tightly integrated
with the translator pass (e.g., tracking the type all the way from the
input to the query instead of locally analyzing the pipe subquery).
Comment on lines 447 to 448
// If we're spreading an unknown type into this record, we don't
// the result at all. Return unknown for the whole thing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
// If we're spreading an unknown type into this record, we don't
// the result at all. Return unknown for the whole thing.
// If we're spreading an unknown type into this record, we don't
// know the result at all. Return unknown for the whole thing.

Comment on lines 892 to 904
func recordOf(typ super.Type) *super.TypeRecord {
switch typ := super.TypeUnder(typ).(type) {
case *super.TypeRecord:
return typ
case *super.TypeUnion:
for _, typ := range typ.Types {
if typ := recordOf(typ); typ != nil {
return typ
}
}
}
return nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Put this in schema.go after newPipeSchema since that's where it's called.

@mccanne mccanne merged commit b3970e0 into main Oct 14, 2025
3 checks passed
@mccanne mccanne deleted the pipe-schema branch October 14, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants