mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-11 08:26:18 +00:00
Support the ARRAY type of Snowflake (#699)
* Snowflake Array * Use the array data type * Try to fix build * Try to fix build * Change Array to option * Remove unused import
This commit is contained in:
parent
bbf32a9e81
commit
0f7e144890
5 changed files with 52 additions and 21 deletions
|
@ -3672,13 +3672,17 @@ impl<'a> Parser<'a> {
|
|||
Keyword::ENUM => Ok(DataType::Enum(self.parse_string_values()?)),
|
||||
Keyword::SET => Ok(DataType::Set(self.parse_string_values()?)),
|
||||
Keyword::ARRAY => {
|
||||
// Hive array syntax. Note that nesting arrays - or other Hive syntax
|
||||
// that ends with > will fail due to "C++" problem - >> is parsed as
|
||||
// Token::ShiftRight
|
||||
self.expect_token(&Token::Lt)?;
|
||||
let inside_type = self.parse_data_type()?;
|
||||
self.expect_token(&Token::Gt)?;
|
||||
Ok(DataType::Array(Box::new(inside_type)))
|
||||
if dialect_of!(self is SnowflakeDialect) {
|
||||
Ok(DataType::Array(None))
|
||||
} else {
|
||||
// Hive array syntax. Note that nesting arrays - or other Hive syntax
|
||||
// that ends with > will fail due to "C++" problem - >> is parsed as
|
||||
// Token::ShiftRight
|
||||
self.expect_token(&Token::Lt)?;
|
||||
let inside_type = self.parse_data_type()?;
|
||||
self.expect_token(&Token::Gt)?;
|
||||
Ok(DataType::Array(Some(Box::new(inside_type))))
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.prev_token();
|
||||
|
@ -3697,7 +3701,7 @@ impl<'a> Parser<'a> {
|
|||
// Keyword::ARRAY syntax from above
|
||||
while self.consume_token(&Token::LBracket) {
|
||||
self.expect_token(&Token::RBracket)?;
|
||||
data = DataType::Array(Box::new(data))
|
||||
data = DataType::Array(Some(Box::new(data)))
|
||||
}
|
||||
Ok(data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue