@@ -491,11 +491,6 @@ class Parser(parser.Parser):
491491 LOG_DEFAULTS_TO_LN = True
492492 SUPPORTS_IMPLICIT_UNNEST = True
493493
494- ID_VAR_TOKENS = {
495- * parser .Parser .ID_VAR_TOKENS ,
496- TokenType .EXPORT ,
497- }
498-
499494 FUNCTIONS = {
500495 ** parser .Parser .FUNCTIONS ,
501496 "CONTAINS_SUBSTR" : _build_contains_substring ,
@@ -837,47 +832,13 @@ def _parse_features_at_time(self) -> exp.FeaturesAtTime:
837832 return expr
838833
839834 def _parse_export_data (self ) -> exp .Export :
840- # https://cloud.google.com/bigquery/docs/reference/standard-sql/export-statements
841- if not self ._match_text_seq ("DATA" ):
842- self .raise_error ("Expected 'DATA' after 'EXPORT'" )
843-
844- with_connection = None
845- options = None
846-
847- if self ._match_text_seq ("WITH" , "CONNECTION" ):
848- parts = []
849- while True :
850- part = self ._parse_var ()
851- if not part :
852- break
853- parts .append (part .name )
854- if not self ._match (TokenType .DOT ):
855- break
856-
857- if not parts :
858- self .raise_error ("Expected connection name after WITH CONNECTION" )
859-
860- with_connection = exp .Identifier (this = "." .join (parts ))
861-
862- if self ._match_text_seq ("OPTIONS" ):
863- self ._match (TokenType .L_PAREN )
864- options = self ._parse_properties ()
865- self ._match (TokenType .R_PAREN )
866- else :
867- self .raise_error ("Expected 'OPTIONS' after 'EXPORT DATA'" )
868-
869- self ._match_text_seq ("AS" )
870-
871- # Parse the full SELECT statement
872- query = self ._parse_statement ()
873- if not isinstance (query , exp .Select ):
874- self .raise_error ("Expected SELECT statement in EXPORT DATA" )
835+ self ._match_text_seq ("DATA" )
875836
876837 return self .expression (
877838 exp .Export ,
878- this = query ,
879- with_connection = with_connection ,
880- options = options ,
839+ connection = self . _match_text_seq ( "WITH" , "CONNECTION" ) and self . _parse_table_parts () ,
840+ options = self . _parse_properties () ,
841+ this = self . _match_text_seq ( "AS" ) and self . _parse_select () ,
881842 )
882843
883844 class Generator (generator .Generator ):
@@ -1288,11 +1249,3 @@ def cast_sql(self, expression: exp.Cast, safe_prefix: t.Optional[str] = None) ->
12881249 return f"{ self .sql (expression , 'to' )} { self .sql (this )} "
12891250
12901251 return super ().cast_sql (expression , safe_prefix = safe_prefix )
1291-
1292- def export_sql (self , expression : exp .Export ) -> str :
1293- this = self .sql (expression , "this" )
1294- with_connection = self .sql (expression , "with_connection" )
1295- with_connection = f"WITH CONNECTION { with_connection } " if with_connection else ""
1296- options = self .sql (expression , "options" )
1297- options = f"{ options } " if options else ""
1298- return f"EXPORT DATA { with_connection } { options } { this } "
0 commit comments