Skip to content
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

Add parsing support for column list with subquery alias #8884

Merged
merged 8 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ type (
Partitions Partitions
As TableIdent
Hints *IndexHints
Columns Columns
}

// JoinTableExpr represents a TableExpr that's a JOIN operation.
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion go/vt/sqlparser/ast_equals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ func (node *AliasedTableExpr) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "%v%v", node.Expr, node.Partitions)
if !node.As.IsEmpty() {
buf.astPrintf(node, " as %v", node.As)
if len(node.Columns) != 0 {
buf.astPrintf(node, "%v", node.Columns)
}
}
if node.Hints != nil {
// Hint node provides the space padding.
Expand Down
3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go/vt/sqlparser/ast_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast_visit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion go/vt/sqlparser/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ var (
output: "select 1 from dual",
}, {
input: "select 1 from t",
}, {
input: "select * from (select 1) as x(user)",
output: "select * from (select 1 from dual) as x(`user`)",
}, {
input: "select user from (select id from users ) as x(user)",
output: "select `user` from (select id from users) as x(`user`)",
}, {
input: "select name, numbers from (select * from users) as x(name, numbers)",
output: "select `name`, numbers from (select * from users) as x(`name`, numbers)",
}, {
input: "select * from information_schema.columns",
output: "select * from information_schema.`columns`",
Expand Down Expand Up @@ -2131,6 +2140,9 @@ func TestInvalid(t *testing.T) {
}, {
input: "select a from x order by y union select a from c",
err: "syntax error",
}, {
input: "select `name`, numbers from (select * from users) as x()",
err: "syntax error at position 57",
}, {
input: "select next 2 values from seq union select next value from seq",
err: "syntax error at position 36 near 'union'",
Expand Down
Loading