@@ -283,6 +283,9 @@ pub enum Expr {
283283 Subquery ( Box < Query > ) ,
284284 /// The `LISTAGG` function `SELECT LISTAGG(...) WITHIN GROUP (ORDER BY ...)`
285285 ListAgg ( ListAgg ) ,
286+ /// bigquery structs https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#struct_type
287+ /// `STRUCT( expr1 [AS field_name] [, ... ])`
288+ Struct ( Struct ) ,
286289}
287290
288291impl fmt:: Display for Expr {
@@ -458,6 +461,7 @@ impl fmt::Display for Expr {
458461 Expr :: Exists ( s) => write ! ( f, "EXISTS ({})" , s) ,
459462 Expr :: Subquery ( s) => write ! ( f, "({})" , s) ,
460463 Expr :: ListAgg ( listagg) => write ! ( f, "{}" , listagg) ,
464+ Expr :: Struct ( strct) => write ! ( f, "{}" , strct) ,
461465 }
462466 }
463467}
@@ -1161,6 +1165,28 @@ impl fmt::Display for ListAgg {
11611165 }
11621166}
11631167
1168+ /// A `STRUCT` invocation `STRUCT( expr1 [AS field_name] [, ... ])`
1169+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1170+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1171+ pub struct Struct {
1172+ pub fields : Vec < ( Expr , Option < Ident > ) > ,
1173+ }
1174+
1175+ impl fmt:: Display for Struct {
1176+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1177+ write ! ( f, "STRUCT(" ) ?;
1178+ let mut delim = "" ;
1179+ for ( expr, maybe_alias) in self . fields . iter ( ) {
1180+ write ! ( f, "{}{}" , delim, expr) ?;
1181+ if let Some ( alias) = maybe_alias {
1182+ write ! ( f, " AS {}" , alias) ?;
1183+ }
1184+ delim = ", " ;
1185+ }
1186+ write ! ( f, ")" )
1187+ }
1188+ }
1189+
11641190/// The `ON OVERFLOW` clause of a LISTAGG invocation
11651191#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
11661192#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
0 commit comments