mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
Fix incorrect parsing of JsonAccess bracket notation after cast in Snowflake (#1708)
This commit is contained in:
parent
0b8ba91156
commit
86abbd6028
6 changed files with 53 additions and 10 deletions
|
|
@ -8943,16 +8943,13 @@ impl<'a> Parser<'a> {
|
|||
_ => self.expected_at("a data type name", next_token_index),
|
||||
}?;
|
||||
|
||||
// Parse array data types. Note: this is postgresql-specific and different from
|
||||
// Keyword::ARRAY syntax from above
|
||||
while self.consume_token(&Token::LBracket) {
|
||||
let size = if dialect_of!(self is GenericDialect | DuckDbDialect | PostgreSqlDialect) {
|
||||
self.maybe_parse(|p| p.parse_literal_uint())?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.expect_token(&Token::RBracket)?;
|
||||
data = DataType::Array(ArrayElemTypeDef::SquareBracket(Box::new(data), size))
|
||||
if self.dialect.supports_array_typedef_size() {
|
||||
// Parse array data type size
|
||||
while self.consume_token(&Token::LBracket) {
|
||||
let size = self.maybe_parse(|p| p.parse_literal_uint())?;
|
||||
self.expect_token(&Token::RBracket)?;
|
||||
data = DataType::Array(ArrayElemTypeDef::SquareBracket(Box::new(data), size))
|
||||
}
|
||||
}
|
||||
Ok((data, trailing_bracket))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue