mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Add support for CREATE SCHEMA WITH ( <properties> )
(#1877)
Some checks are pending
Rust / test (stable) (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
Some checks are pending
Rust / test (stable) (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
This commit is contained in:
parent
84c3a1b325
commit
40d12b98bd
3 changed files with 23 additions and 0 deletions
|
@ -3725,6 +3725,14 @@ pub enum Statement {
|
||||||
/// `<schema name> | AUTHORIZATION <schema authorization identifier> | <schema name> AUTHORIZATION <schema authorization identifier>`
|
/// `<schema name> | AUTHORIZATION <schema authorization identifier> | <schema name> AUTHORIZATION <schema authorization identifier>`
|
||||||
schema_name: SchemaName,
|
schema_name: SchemaName,
|
||||||
if_not_exists: bool,
|
if_not_exists: bool,
|
||||||
|
/// Schema properties.
|
||||||
|
///
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE SCHEMA myschema WITH (key1='value1');
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// [Trino](https://trino.io/docs/current/sql/create-schema.html)
|
||||||
|
with: Option<Vec<SqlOption>>,
|
||||||
/// Schema options.
|
/// Schema options.
|
||||||
///
|
///
|
||||||
/// ```sql
|
/// ```sql
|
||||||
|
@ -5585,6 +5593,7 @@ impl fmt::Display for Statement {
|
||||||
Statement::CreateSchema {
|
Statement::CreateSchema {
|
||||||
schema_name,
|
schema_name,
|
||||||
if_not_exists,
|
if_not_exists,
|
||||||
|
with,
|
||||||
options,
|
options,
|
||||||
default_collate_spec,
|
default_collate_spec,
|
||||||
} => {
|
} => {
|
||||||
|
@ -5599,6 +5608,10 @@ impl fmt::Display for Statement {
|
||||||
write!(f, " DEFAULT COLLATE {collate}")?;
|
write!(f, " DEFAULT COLLATE {collate}")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(with) = with {
|
||||||
|
write!(f, " WITH ({})", display_comma_separated(with))?;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(options) = options {
|
if let Some(options) = options {
|
||||||
write!(f, " OPTIONS({})", display_comma_separated(options))?;
|
write!(f, " OPTIONS({})", display_comma_separated(options))?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4862,6 +4862,12 @@ impl<'a> Parser<'a> {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let with = if self.peek_keyword(Keyword::WITH) {
|
||||||
|
Some(self.parse_options(Keyword::WITH)?)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let options = if self.peek_keyword(Keyword::OPTIONS) {
|
let options = if self.peek_keyword(Keyword::OPTIONS) {
|
||||||
Some(self.parse_options(Keyword::OPTIONS)?)
|
Some(self.parse_options(Keyword::OPTIONS)?)
|
||||||
} else {
|
} else {
|
||||||
|
@ -4871,6 +4877,7 @@ impl<'a> Parser<'a> {
|
||||||
Ok(Statement::CreateSchema {
|
Ok(Statement::CreateSchema {
|
||||||
schema_name,
|
schema_name,
|
||||||
if_not_exists,
|
if_not_exists,
|
||||||
|
with,
|
||||||
options,
|
options,
|
||||||
default_collate_spec,
|
default_collate_spec,
|
||||||
})
|
})
|
||||||
|
|
|
@ -4268,6 +4268,9 @@ fn parse_create_schema() {
|
||||||
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a OPTIONS(key1 = 'value1')"#);
|
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a OPTIONS(key1 = 'value1')"#);
|
||||||
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a OPTIONS()"#);
|
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a OPTIONS()"#);
|
||||||
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a DEFAULT COLLATE 'und:ci' OPTIONS()"#);
|
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a DEFAULT COLLATE 'und:ci' OPTIONS()"#);
|
||||||
|
verified_stmt(r#"CREATE SCHEMA a.b.c WITH (key1 = 'value1', key2 = 'value2')"#);
|
||||||
|
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a WITH (key1 = 'value1')"#);
|
||||||
|
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a WITH ()"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue