Skip to content

Commit

Permalink
fix again
Browse files Browse the repository at this point in the history
Signed-off-by: TennyZhuang <[email protected]>
  • Loading branch information
TennyZhuang committed May 8, 2024
1 parent 9af6dee commit 879e4b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/sqlparser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,12 @@ impl Parser {
expected_depth: &mut Option<usize>,
) -> Result<Expr, ParserError> {
Ok(if self.consume_token(&Token::LBracket) {
if self.consume_token(&Token::RBracket) {
return Ok(Expr::Array(Array {
elem: vec![],
named: false,
}));
}
let exprs = self.parse_comma_separated(|parser| {
parser.parse_array_inner(depth + 1, expected_depth)
})?;
Expand All @@ -1247,11 +1253,6 @@ impl Parser {
// Only top-level array is named.
named: false,
})
} else if self.peek_token() == Token::RBracket {
Expr::Array(Array {
elem: vec![],
named: false,
})
} else {
if let Some(expected_depth) = *expected_depth {
match depth.cmp(&expected_depth) {
Expand Down
2 changes: 2 additions & 0 deletions src/sqlparser/tests/testdata/array.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
formatted_sql: SELECT ARRAY[[1, 2], [3, 4]]
- input: SELECT ARRAY[ARRAY[1,2],ARRAY[3,4]]
formatted_sql: SELECT ARRAY[ARRAY[1, 2], ARRAY[3, 4]]
- input: SELECT ARRAY[[],[]]
formatted_sql: SELECT ARRAY[[], []]
- input: SELECT ARRAY[[1,2],3]
error_msg: |-
sql parser error: Expected ], found: 3 at line:1, column:21
Expand Down

0 comments on commit 879e4b5

Please sign in to comment.