-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(spansql): support subquery in View Join #13266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -90,7 +90,7 @@ func ParseDML(filename, s string) (*DML, error) { | |||||
| return dml, nil | ||||||
| } | ||||||
|
|
||||||
| func parseStatements(stmts statements, filename string, s string) error { | ||||||
| func parseStatements(stmts statements, filename, s string) error { | ||||||
| p := newParser(filename, s) | ||||||
|
|
||||||
| stmts.setFilename(filename) | ||||||
|
|
@@ -4655,8 +4655,26 @@ func (p *parser) parseLit() (Expr, *parseError) { | |||||
| return BytesLiteral(tok.string), nil | ||||||
| } | ||||||
|
|
||||||
| // Handle parenthesized expressions. | ||||||
| // Handle parenthesized expressions and scalar subqueries. | ||||||
| // NOTE: The opening "(" has already been consumed by p.next() above (line 4638). | ||||||
| // The parser is now positioned right after the "(", ready to parse the contents. | ||||||
| if tok.value == "(" { | ||||||
| // Look ahead to see if this is a subquery like: (SELECT ...) | ||||||
| // p.sniff("SELECT") peeks at the next token without consuming it. | ||||||
| if p.sniff("SELECT") { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current lookahead only checks for To fix this, you should also check for the For example, a query like I'd also recommend adding a test case to
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WITH is currently not supported and this PR does not aim to resolve it either as it would grow to large. |
||||||
| // Parse the subquery starting from the current position (after the "(") | ||||||
| q, err := p.parseQuery() | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
| if err := p.expect(")"); err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
| return ScalarSubquery{Query: q}, nil | ||||||
| } | ||||||
|
|
||||||
| // Regular parenthesized expression like: (1 + 2) | ||||||
| // Parse the inner expression starting from the current position (after the "(") | ||||||
| e, err := p.parseExpr() | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when running vet.sh from the workflows folder these changes were applied