LucaCappelletti94 commented on code in PR #2356:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2356#discussion_r3649992033
##########
src/parser/mod.rs:
##########
@@ -2904,15 +2903,19 @@ impl<'a> Parser<'a> {
self.expect_token(&Token::LParen)?;
let expr = self.parse_expr()?;
self.expect_keyword_is(Keyword::AS)?;
- let data_type = self.parse_data_type()?;
- let array = self.parse_keyword(Keyword::ARRAY);
+ let mut data_type = self.parse_data_type()?;
+ // A trailing `ARRAY` keyword makes the target an array type, e.g.
MySQL's
+ // `CAST(... AS UNSIGNED ARRAY)`. PostgreSQL already consumes it while
+ // parsing the data type, so the guard avoids wrapping it twice.
+ if !matches!(data_type, DataType::Array(_)) &&
self.parse_keyword(Keyword::ARRAY) {
+ data_type =
DataType::Array(ArrayElemTypeDef::Keyword(Box::new(data_type), None));
+ }
Review Comment:
That guard existed because the keyword form used to be gated off for MySQL,
see
https://github.com/apache/datafusion-sqlparser-rs/pull/2356#discussion_r3649991312
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]