mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-10 05:52:13 +00:00
Snowflake: Support CREATE VIEW myview IF NOT EXISTS
(#1961)
Some checks are pending
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
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
Some checks are pending
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
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
This commit is contained in:
parent
15d8bfea62
commit
91273703d4
4 changed files with 56 additions and 6 deletions
|
@ -3255,6 +3255,17 @@ pub enum Statement {
|
|||
materialized: bool,
|
||||
/// View name
|
||||
name: ObjectName,
|
||||
/// If `if_not_exists` is true, this flag is set to true if the view name comes before the `IF NOT EXISTS` clause.
|
||||
/// Example:
|
||||
/// ```sql
|
||||
/// CREATE VIEW myview IF NOT EXISTS AS SELECT 1`
|
||||
/// ```
|
||||
/// Otherwise, the flag is set to false if the view name comes after the clause
|
||||
/// Example:
|
||||
/// ```sql
|
||||
/// CREATE VIEW IF NOT EXISTS myview AS SELECT 1`
|
||||
/// ```
|
||||
name_before_not_exists: bool,
|
||||
columns: Vec<ViewColumnDef>,
|
||||
query: Box<Query>,
|
||||
options: CreateTableOptions,
|
||||
|
@ -4994,6 +5005,7 @@ impl fmt::Display for Statement {
|
|||
temporary,
|
||||
to,
|
||||
params,
|
||||
name_before_not_exists,
|
||||
} => {
|
||||
write!(
|
||||
f,
|
||||
|
@ -5006,11 +5018,18 @@ impl fmt::Display for Statement {
|
|||
}
|
||||
write!(
|
||||
f,
|
||||
"{materialized}{temporary}VIEW {if_not_exists}{name}{to}",
|
||||
"{materialized}{temporary}VIEW {if_not_and_name}{to}",
|
||||
if_not_and_name = if *if_not_exists {
|
||||
if *name_before_not_exists {
|
||||
format!("{name} IF NOT EXISTS")
|
||||
} else {
|
||||
format!("IF NOT EXISTS {name}")
|
||||
}
|
||||
} else {
|
||||
format!("{name}")
|
||||
},
|
||||
materialized = if *materialized { "MATERIALIZED " } else { "" },
|
||||
name = name,
|
||||
temporary = if *temporary { "TEMPORARY " } else { "" },
|
||||
if_not_exists = if *if_not_exists { "IF NOT EXISTS " } else { "" },
|
||||
to = to
|
||||
.as_ref()
|
||||
.map(|to| format!(" TO {to}"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue