Skip to content

cleanly separate pipe from and SQL FROM#6405

Merged
mccanne merged 2 commits intomainfrom
from-sep
Dec 1, 2025
Merged

cleanly separate pipe from and SQL FROM#6405
mccanne merged 2 commits intomainfrom
from-sep

Conversation

@mccanne
Copy link
Collaborator

@mccanne mccanne commented Nov 30, 2025

This commit cleanly separates the syntax of the pipe-operator "from" and the SQL FROM clause. This means that table aliases are no longer allowed with pipe from (even though they were ignored). Also, a relational FROM is no longer possible without a SELECT clause (required a "SELECT *" to do a straight relational join). We can revisit this if there's interest as the grammar should be able to handle it.

This better aligns the PEG grammar and semantic pass with the actual SQL syntax and will make it easier to document the FROM clause and the "from" pipe operator.

Documentation is forthcoming from the book-sql branch.

This commit cleanly separates the syntax of the pipe-operator "from"
and the SQL FROM clause.  This means that table aliases are no longer
allowed with pipe from (even though they were ignored).  Also, a
relational FROM is no longer possible without a SELECT clause
(required a "SELECT *" to do a straight relational join).  We can
revisit this if there's interest as the grammar should be able
to handle it.

This better aligns the PEG grammar and semantic pass with the
actual SQL syntax and will make it easier to document the
FROM clause and the "from" pipe operator.

Documentation is forthcoming from the book-sql branch.
func (*FromItem) sqlTableInputNode() {}
func (*SQLPipe) sqlTableInputNode() {}

// SQL table expression structure all of which implement FromEntity
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is now out of date.

Comment on lines +755 to +762
s := &ast.FromItem{
Source: source.(ast.FromSource),
Loc: loc(c),
}
if args != nil {
s.Args = sliceOf[ast.OpArg](args)
}
return s, 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: sliceOf returns nil for a nil argument.

Suggested change
s := &ast.FromItem{
Source: source.(ast.FromSource),
Loc: loc(c),
}
if args != nil {
s.Args = sliceOf[ast.OpArg](args)
}
return s, nil
return &ast.FromItem{
Source: source.(ast.FromSource),
Args: sliceOf[ast.OpArg](args),
Loc: loc(c),
}, nil

@mccanne mccanne merged commit a814e1b into main Dec 1, 2025
2 checks passed
@mccanne mccanne deleted the from-sep branch December 1, 2025 19:24
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.

2 participants