mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-14 07:52:02 +00:00
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
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:
parent
5ec953bd78
commit
97a5b61a73
4 changed files with 309 additions and 2 deletions
|
@ -4355,6 +4355,15 @@ pub enum Statement {
|
|||
///
|
||||
/// See [ReturnStatement]
|
||||
Return(ReturnStatement),
|
||||
/// Export data statement
|
||||
///
|
||||
/// Example:
|
||||
/// ```sql
|
||||
/// EXPORT DATA OPTIONS(uri='gs://bucket/folder/*', format='PARQUET', overwrite=true) AS
|
||||
/// SELECT field1, field2 FROM mydataset.table1 ORDER BY field1 LIMIT 10
|
||||
/// ```
|
||||
/// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/export-statements)
|
||||
ExportData(ExportData),
|
||||
/// ```sql
|
||||
/// CREATE [OR REPLACE] USER <user> [IF NOT EXISTS]
|
||||
/// ```
|
||||
|
@ -6198,6 +6207,7 @@ impl fmt::Display for Statement {
|
|||
Statement::Return(r) => write!(f, "{r}"),
|
||||
Statement::List(command) => write!(f, "LIST {command}"),
|
||||
Statement::Remove(command) => write!(f, "REMOVE {command}"),
|
||||
Statement::ExportData(e) => write!(f, "{e}"),
|
||||
Statement::CreateUser(s) => write!(f, "{s}"),
|
||||
}
|
||||
}
|
||||
|
@ -10144,6 +10154,34 @@ impl fmt::Display for MemberOf {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct ExportData {
|
||||
pub options: Vec<SqlOption>,
|
||||
pub query: Box<Query>,
|
||||
pub connection: Option<ObjectName>,
|
||||
}
|
||||
|
||||
impl fmt::Display for ExportData {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(connection) = &self.connection {
|
||||
write!(
|
||||
f,
|
||||
"EXPORT DATA WITH CONNECTION {connection} OPTIONS({}) AS {}",
|
||||
display_comma_separated(&self.options),
|
||||
self.query
|
||||
)
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
"EXPORT DATA OPTIONS({}) AS {}",
|
||||
display_comma_separated(&self.options),
|
||||
self.query
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Creates a user
|
||||
///
|
||||
/// Syntax:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue