@@ -1123,9 +1123,8 @@ impl<'a> Parser<'a> {
11231123 Keyword::MATCH if dialect_of!(self is MySqlDialect | GenericDialect) => {
11241124 Ok(Some(self.parse_match_against()?))
11251125 }
1126- Keyword::STRUCT if dialect_of!(self is BigQueryDialect | GenericDialect) => {
1127- self.prev_token();
1128- Ok(Some(self.parse_bigquery_struct_literal()?))
1126+ Keyword::STRUCT if self.dialect.supports_struct_literal() => {
1127+ Ok(Some(self.parse_struct_literal()?))
11291128 }
11301129 Keyword::PRIOR if matches!(self.state, ParserState::ConnectBy) => {
11311130 let expr = self.parse_subexpr(self.dialect.prec_value(Precedence::PlusMinus))?;
@@ -2383,15 +2382,16 @@ impl<'a> Parser<'a> {
23832382 }
23842383 }
23852384
2386- /// Bigquery specific: Parse a struct literal
23872385 /// Syntax
23882386 /// ```sql
23892387 /// -- typed
23902388 /// STRUCT<[field_name] field_type, ...>( expr1 [, ... ])
23912389 /// -- typeless
23922390 /// STRUCT( expr1 [AS field_name] [, ... ])
23932391 /// ```
2394- fn parse_bigquery_struct_literal(&mut self) -> Result<Expr, ParserError> {
2392+ fn parse_struct_literal(&mut self) -> Result<Expr, ParserError> {
2393+ // Parse the fields definition if exist `<[field_name] field_type, ...>`
2394+ self.prev_token();
23952395 let (fields, trailing_bracket) =
23962396 self.parse_struct_type_def(Self::parse_struct_field_def)?;
23972397 if trailing_bracket.0 {
@@ -2401,6 +2401,7 @@ impl<'a> Parser<'a> {
24012401 );
24022402 }
24032403
2404+ // Parse the struct values `(expr1 [, ... ])`
24042405 self.expect_token(&Token::LParen)?;
24052406 let values = self
24062407 .parse_comma_separated(|parser| parser.parse_struct_field_expr(!fields.is_empty()))?;
@@ -2409,13 +2410,13 @@ impl<'a> Parser<'a> {
24092410 Ok(Expr::Struct { values, fields })
24102411 }
24112412
2412- /// Parse an expression value for a bigquery struct [1]
2413+ /// Parse an expression value for a struct literal
24132414 /// Syntax
24142415 /// ```sql
24152416 /// expr [AS name]
24162417 /// ```
24172418 ///
2418- /// Parameter typed_syntax is set to true if the expression
2419+ /// For biquery [1], Parameter typed_syntax is set to true if the expression
24192420 /// is to be parsed as a field expression declared using typed
24202421 /// struct syntax [2], and false if using typeless struct syntax [3].
24212422 ///
0 commit comments