File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10146,16 +10146,26 @@ impl fmt::Display for MemberOf {
1014610146pub struct ExportData {
1014710147 pub options : Vec < SqlOption > ,
1014810148 pub query : Box < Query > ,
10149+ pub connection : Option < ObjectName > ,
1014910150}
1015010151
1015110152impl fmt:: Display for ExportData {
1015210153 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10153- write ! (
10154- f,
10155- "EXPORT DATA OPTIONS({}) AS {}" ,
10156- display_comma_separated( & self . options) ,
10157- self . query
10158- )
10154+ if let Some ( connection) = & self . connection {
10155+ write ! (
10156+ f,
10157+ "EXPORT DATA WITH CONNECTION {connection} OPTIONS({}) AS {}" ,
10158+ display_comma_separated( & self . options) ,
10159+ self . query
10160+ )
10161+ } else {
10162+ write ! (
10163+ f,
10164+ "EXPORT DATA OPTIONS({}) AS {}" ,
10165+ display_comma_separated( & self . options) ,
10166+ self . query
10167+ )
10168+ }
1015910169 }
1016010170}
1016110171/// Creates a user
Original file line number Diff line number Diff line change @@ -531,11 +531,16 @@ impl Spanned for Statement {
531531 Statement :: Print { .. } => Span :: empty ( ) ,
532532 Statement :: Return { .. } => Span :: empty ( ) ,
533533 Statement :: List ( ..) | Statement :: Remove ( ..) => Span :: empty ( ) ,
534- Statement :: ExportData ( ExportData { options, query } ) => union_spans (
534+ Statement :: ExportData ( ExportData {
535+ options,
536+ query,
537+ connection,
538+ } ) => union_spans (
535539 options
536540 . iter ( )
537541 . map ( |i| i. span ( ) )
538- . chain ( core:: iter:: once ( query. span ( ) ) ) ,
542+ . chain ( core:: iter:: once ( query. span ( ) ) )
543+ . chain ( connection. iter ( ) . map ( |i| i. span ( ) ) ) ,
539544 ) ,
540545 Statement :: CreateUser ( ..) => Span :: empty ( ) ,
541546 }
Original file line number Diff line number Diff line change @@ -16513,13 +16513,23 @@ impl<'a> Parser<'a> {
1651316513
1651416514 fn parse_export(&mut self) -> Result<Statement, ParserError> {
1651516515 self.expect_keyword(Keyword::DATA)?;
16516+
16517+ let connection = if self.parse_keywords(&[Keyword::WITH, Keyword::CONNECTION]) {
16518+ Some(self.parse_object_name(false)?)
16519+ } else {
16520+ None
16521+ };
1651616522 self.expect_keyword(Keyword::OPTIONS)?;
1651716523 self.expect_token(&Token::LParen)?;
1651816524 let options = self.parse_comma_separated(|p| p.parse_sql_option())?;
1651916525 self.expect_token(&Token::RParen)?;
1652016526 self.expect_keyword(Keyword::AS)?;
1652116527 let query = self.parse_query()?;
16522- Ok(Statement::ExportData(ExportData { options, query }))
16528+ Ok(Statement::ExportData(ExportData {
16529+ options,
16530+ query,
16531+ connection,
16532+ }))
1652316533 }
1652416534
1652516535 /// Consume the parser and return its underlying token buffer
Original file line number Diff line number Diff line change @@ -2577,4 +2577,13 @@ fn test_export() {
25772577 ") AS " ,
25782578 "SELECT field1, field2 FROM mydataset.table1 ORDER BY field1 LIMIT 10" ,
25792579 ) ) ;
2580+
2581+ bigquery ( ) . verified_stmt ( concat ! (
2582+ "EXPORT DATA WITH CONNECTION myconnection.myproject.us OPTIONS(" ,
2583+ "uri = 'gs://bucket/folder/*', " ,
2584+ "format = 'PARQUET', " ,
2585+ "overwrite = true" ,
2586+ ") AS " ,
2587+ "SELECT field1, field2 FROM mydataset.table1 ORDER BY field1 LIMIT 10" ,
2588+ ) ) ;
25802589}
You can’t perform that action at this time.
0 commit comments