Skip to content

Commit

Permalink
fix: fix the parser
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed Jun 7, 2024
1 parent a154859 commit a651297
Show file tree
Hide file tree
Showing 4 changed files with 9,180 additions and 9,116 deletions.
21 changes: 10 additions & 11 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3004,25 +3004,25 @@ var (
}, {
input: `SELECT * FROM JSON_TABLE('[ {"c1": null} ]','$[*]' COLUMNS( c1 INT PATH '$.c1' ERROR ON ERROR )) as jt`,
output: `select * from json_table('[ {\"c1\": null} ]', '$[*]' columns(
c1 INT path '$.c1' error on error
c1 INT path '$.c1' error on error
)
) as jt`,
}, {
input: `SELECT * FROM JSON_TABLE( '[{"a": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}]', '$[*]' COLUMNS(a INT PATH '$.a', NESTED PATH '$.b[*]' COLUMNS (b1 INT PATH '$'), NESTED PATH '$.b[*]' COLUMNS (b2 INT PATH '$'))) AS jt`,
output: `select * from json_table('[{\"a\": 1, \"b\": [11,111]}, {\"a\": 2, \"b\": [22,222]}]', '$[*]' columns(
a INT path '$.a' ,
nested path '$.b[*]' columns(
b1 INT path '$'
b1 INT path '$'
),
nested path '$.b[*]' columns(
b2 INT path '$'
b2 INT path '$'
)
)
) as jt`,
}, {
input: `SELECT * FROM JSON_TABLE('[ {"c1": null} ]','$[*]' COLUMNS( c1 INT PATH '$.c1' ERROR ON ERROR )) as jt`,
output: `select * from json_table('[ {\"c1\": null} ]', '$[*]' columns(
c1 INT path '$.c1' error on error
c1 INT path '$.c1' error on error
)
) as jt`,
}, {
Expand All @@ -3031,23 +3031,23 @@ var (
rowid for ordinality,
ac VARCHAR(100) path '$.a' default '111' on empty default '999' on error ,
aj JSON path '$.a' default '{\"x\": 333}' on empty ,
bx INT exists path '$.b'
bx INT exists path '$.b'
)
) as tt`,
}, {
input: `SELECT * FROM JSON_TABLE( '[ {"a": 1, "b": [11,111]}, {"a": 2, "b": [22,222]}, {"a":3}]', '$[*]' COLUMNS( a INT PATH '$.a', NESTED PATH '$.b[*]' COLUMNS (b INT PATH '$') ) ) AS jt WHERE b IS NOT NULL`,
output: `select * from json_table('[ {\"a\": 1, \"b\": [11,111]}, {\"a\": 2, \"b\": [22,222]}, {\"a\":3}]', '$[*]' columns(
a INT path '$.a' ,
nested path '$.b[*]' columns(
b INT path '$'
b INT path '$'
)
)
) as jt where b is not null`,
}, {
input: `SELECT * FROM JSON_TABLE( '[{"x":2,"y":"8"},{"x":"3","y":"7"},{"x":"4","y":6}]', "$[1]" COLUMNS( xval VARCHAR(100) PATH "$.x", yval VARCHAR(100) PATH "$.y" ) ) AS jt1`,
output: `select * from json_table('[{\"x\":2,\"y\":\"8\"},{\"x\":\"3\",\"y\":\"7\"},{\"x\":\"4\",\"y\":6}]', '$[1]' columns(
xval VARCHAR(100) path '$.x' ,
yval VARCHAR(100) path '$.y'
yval VARCHAR(100) path '$.y'
)
) as jt1`,
}, {
Expand All @@ -3059,7 +3059,7 @@ var (
bpath VARCHAR(10) path '$.c' ,
ord for ordinality,
nested path '$.l[*]' columns(
lpath varchar(10) path '$'
lpath varchar(10) path '$'
)
)
)
Expand All @@ -3068,7 +3068,7 @@ var (
input: `SELECT * FROM JSON_TABLE('[{"x":2,"y":"8"},{"x":"3","y":"7"},{"x":"4","y":6}]', "$[1]" COLUMNS( xval VARCHAR(100) PATH "$.x", yval VARCHAR(100) PATH "$.y")) AS jt1;`,
output: `select * from json_table('[{\"x\":2,\"y\":\"8\"},{\"x\":\"3\",\"y\":\"7\"},{\"x\":\"4\",\"y\":6}]', '$[1]' columns(
xval VARCHAR(100) path '$.x' ,
yval VARCHAR(100) path '$.y'
yval VARCHAR(100) path '$.y'
)
) as jt1`,
}, {
Expand Down Expand Up @@ -3806,8 +3806,7 @@ var (
}, {
input: `select * from tbl where foo > any (select foo from tbl2)`,
}, {
input: `select * from tbl where foo > all (select foo from tbl2)`,
}}
input: `select * from tbl where foo > all (select foo from tbl2)`}}
)

func TestValid(t *testing.T) {
Expand Down
Loading

0 comments on commit a651297

Please sign in to comment.