@@ -245,11 +245,18 @@ pub struct Select {
245245 pub named_window : Vec < NamedWindowDefinition > ,
246246 /// QUALIFY (Snowflake)
247247 pub qualify : Option < Expr > ,
248+ /// BigQuery syntax: `SELECT AS VALUE | SELECT AS STRUCT`
249+ pub value_table_mode : Option < ValueTableMode > ,
248250}
249251
250252impl fmt:: Display for Select {
251253 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
252254 write ! ( f, "SELECT" ) ?;
255+
256+ if let Some ( value_table_mode) = self . value_table_mode {
257+ write ! ( f, " {value_table_mode}" ) ?;
258+ }
259+
253260 if let Some ( ref distinct) = self . distinct {
254261 write ! ( f, " {distinct}" ) ?;
255262 }
@@ -1574,3 +1581,24 @@ impl fmt::Display for JsonTableColumnErrorHandling {
15741581 }
15751582 }
15761583}
1584+
1585+ /// BigQuery supports ValueTables which have 2 modes:
1586+ /// `SELECT AS STRUCT`
1587+ /// `SELECT AS VALUE`
1588+ /// <https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#value_tables>
1589+ #[ derive( Debug , Copy , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
1590+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1591+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
1592+ pub enum ValueTableMode {
1593+ AsStruct ,
1594+ AsValue ,
1595+ }
1596+
1597+ impl fmt:: Display for ValueTableMode {
1598+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1599+ match self {
1600+ ValueTableMode :: AsStruct => write ! ( f, "AS STRUCT" ) ,
1601+ ValueTableMode :: AsValue => write ! ( f, "AS VALUE" ) ,
1602+ }
1603+ }
1604+ }
0 commit comments