feat: add fixed size list support (#1231)

This commit is contained in:
universalmind303 2024-04-23 16:53:03 -05:00 committed by GitHub
parent 39980e8976
commit ce85084deb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 10 deletions

View file

@ -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))
}