-
Notifications
You must be signed in to change notification settings - Fork 627
feat: support export data for bigquery #1976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
/// EXPORT DATA OPTIONS(uri='gs://bucket/folder/*', format='PARQUET', overwrite=true) AS | ||
/// SELECT field1, field2 FROM mydataset.table1 ORDER BY field1 LIMIT 10 | ||
/// ``` | ||
ExportData(ExportData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a link to the bigquery docs where the syntax comes from?
src/parser/mod.rs
Outdated
@@ -645,6 +645,7 @@ impl<'a> Parser<'a> { | |||
Keyword::COMMENT if self.dialect.supports_comment_on() => self.parse_comment(), | |||
Keyword::PRINT => self.parse_print(), | |||
Keyword::RETURN => self.parse_return(), | |||
Keyword::EXPORT => self.parse_export(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do similar to here where we call prev_token()
so that the parse-export()
function is stand alone and able to parse a complete statement?
src/parser/mod.rs
Outdated
@@ -16510,6 +16511,27 @@ impl<'a> Parser<'a> { | |||
} | |||
} | |||
|
|||
fn parse_export(&mut self) -> Result<Statement, ParserError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn parse_export(&mut self) -> Result<Statement, ParserError> { | |
fn parse_export_date(&mut self) -> Result<Statement, ParserError> { |
Could we also add a short description mentioning that this parses a Statement::ExportData
statement? For example
tests/sqlparser_bigquery.rs
Outdated
@@ -2566,3 +2566,24 @@ fn test_struct_trailing_and_nested_bracket() { | |||
) | |||
); | |||
} | |||
|
|||
#[test] | |||
fn test_export() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this introduces a new statement, can we include an assertion on the AST for one of the statements, checking that the returned AST looks like what we expect? For example
Also could we add coverage for some scenarios like the following?
"EXPORT DATA OPTIONS()";
"EXPORT DATA AS SELECT ...";
"EXPORT DATA WITH CONNECTION ... AS SELECT ..."
No description provided.