feat: support export data for bigquery (#1976)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run

This commit is contained in:
Chen Chongchen 2025-07-28 21:17:51 +08:00 committed by GitHub
parent 5ec953bd78
commit 97a5b61a73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 309 additions and 2 deletions

View file

@ -645,6 +645,10 @@ 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.prev_token();
self.parse_export_data()
}
_ => self.expected("an SQL statement", next_token),
},
Token::LParen => {
@ -16523,6 +16527,30 @@ impl<'a> Parser<'a> {
}
}
/// /// Parse a `EXPORT DATA` statement.
///
/// See [Statement::ExportData]
fn parse_export_data(&mut self) -> Result<Statement, ParserError> {
self.expect_keywords(&[Keyword::EXPORT, Keyword::DATA])?;
let connection = if self.parse_keywords(&[Keyword::WITH, Keyword::CONNECTION]) {
Some(self.parse_object_name(false)?)
} else {
None
};
self.expect_keyword(Keyword::OPTIONS)?;
self.expect_token(&Token::LParen)?;
let options = self.parse_comma_separated(|p| p.parse_sql_option())?;
self.expect_token(&Token::RParen)?;
self.expect_keyword(Keyword::AS)?;
let query = self.parse_query()?;
Ok(Statement::ExportData(ExportData {
options,
query,
connection,
}))
}
/// Consume the parser and return its underlying token buffer
pub fn into_tokens(self) -> Vec<TokenWithSpan> {
self.tokens