Conversation
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.
nwt
reviewed
Dec 1, 2025
compiler/ast/sql.go
Outdated
| func (*FromItem) sqlTableInputNode() {} | ||
| func (*SQLPipe) sqlTableInputNode() {} | ||
|
|
||
| // SQL table expression structure all of which implement FromEntity |
nwt
approved these changes
Dec 1, 2025
compiler/parser/parser.peg
Outdated
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 |
Member
There was a problem hiding this comment.
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 |
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.
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.