mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
feat: add fixed size list support (#1231)
This commit is contained in:
parent
39980e8976
commit
ce85084deb
4 changed files with 36 additions and 10 deletions
|
|
@ -6360,7 +6360,7 @@ impl<'a> Parser<'a> {
|
|||
&mut self,
|
||||
) -> Result<(DataType, MatchedTrailingBracket), ParserError> {
|
||||
let next_token = self.next_token();
|
||||
let mut trailing_bracket = false.into();
|
||||
let mut trailing_bracket: MatchedTrailingBracket = false.into();
|
||||
let mut data = match next_token.token {
|
||||
Token::Word(w) => match w.keyword {
|
||||
Keyword::BOOLEAN => Ok(DataType::Boolean),
|
||||
|
|
@ -6580,8 +6580,13 @@ impl<'a> Parser<'a> {
|
|||
// 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)))
|
||||
data = DataType::Array(ArrayElemTypeDef::SquareBracket(Box::new(data), size))
|
||||
}
|
||||
Ok((data, trailing_bracket))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue