Skip to content

Commit 5bc791a

Browse files
committed
address comments
1 parent 3c7fd73 commit 5bc791a

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/ast/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,14 @@ pub enum Expr {
857857
/// Syntax:
858858
/// ```sql
859859
/// STRUCT<[field_name] field_type, ...>( expr1 [, ... ])
860+
///
861+
/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#struct_type)
862+
/// [Databricks](https://docs.databricks.com/en/sql/language-manual/functions/struct.html)
860863
/// ```
861864
Struct {
862865
/// Struct values.
863866
values: Vec<Expr>,
864-
/// BigQuery specific: Struct field definitions.
865-
/// see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#struct_type
867+
/// Struct field definitions.
866868
fields: Vec<StructField>,
867869
},
868870
/// `BigQuery` specific: An named expression in a typeless struct [1]

src/parser/mod.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -2329,25 +2329,21 @@ impl<'a> Parser<'a> {
23292329

23302330
/// Syntax
23312331
/// ```sql
2332-
/// -- typed, specific to bigquery
2332+
/// -- typed
23332333
/// STRUCT<[field_name] field_type, ...>( expr1 [, ... ])
23342334
/// -- typeless
23352335
/// STRUCT( expr1 [AS field_name] [, ... ])
23362336
/// ```
23372337
fn parse_struct_literal(&mut self) -> Result<Expr, ParserError> {
2338-
let mut fields = vec![];
2339-
// Typed struct syntax is only supported by BigQuery
2340-
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#typed_struct_syntax
2341-
if self.dialect.supports_typed_struct_syntax() {
2342-
self.prev_token();
2343-
let trailing_bracket;
2344-
(fields, trailing_bracket) =
2345-
self.parse_struct_type_def(Self::parse_struct_field_def)?;
2346-
if trailing_bracket.0 {
2347-
return parser_err!("unmatched > in STRUCT literal", self.peek_token().location);
2348-
}
2338+
// Parse the fields definition if exist `<[field_name] field_type, ...>`
2339+
self.prev_token();
2340+
let (fields, trailing_bracket) =
2341+
self.parse_struct_type_def(Self::parse_struct_field_def)?;
2342+
if trailing_bracket.0 {
2343+
return parser_err!("unmatched > in STRUCT literal", self.peek_token().location);
23492344
}
23502345

2346+
// Parse the struct values `(expr1 [, ... ])`
23512347
self.expect_token(&Token::LParen)?;
23522348
let values = self
23532349
.parse_comma_separated(|parser| parser.parse_struct_field_expr(!fields.is_empty()))?;

0 commit comments

Comments
 (0)