mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-09 13:40:22 +00:00
Snowflake: support multiple column options in CREATE VIEW
(#1891)
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
This commit is contained in:
parent
b2ab0061c1
commit
1bbc05cdff
10 changed files with 98 additions and 40 deletions
|
@ -10579,17 +10579,7 @@ impl<'a> Parser<'a> {
|
|||
/// Parses a column definition within a view.
|
||||
fn parse_view_column(&mut self) -> Result<ViewColumnDef, ParserError> {
|
||||
let name = self.parse_identifier()?;
|
||||
let options = if (dialect_of!(self is BigQueryDialect | GenericDialect)
|
||||
&& self.parse_keyword(Keyword::OPTIONS))
|
||||
|| (dialect_of!(self is SnowflakeDialect | GenericDialect)
|
||||
&& self.parse_keyword(Keyword::COMMENT))
|
||||
{
|
||||
self.prev_token();
|
||||
self.parse_optional_column_option()?
|
||||
.map(|option| vec![option])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let options = self.parse_view_column_options()?;
|
||||
let data_type = if dialect_of!(self is ClickHouseDialect) {
|
||||
Some(self.parse_data_type()?)
|
||||
} else {
|
||||
|
@ -10602,6 +10592,25 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_view_column_options(&mut self) -> Result<Option<ColumnOptions>, ParserError> {
|
||||
let mut options = Vec::new();
|
||||
loop {
|
||||
let option = self.parse_optional_column_option()?;
|
||||
if let Some(option) = option {
|
||||
options.push(option);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if options.is_empty() {
|
||||
Ok(None)
|
||||
} else if self.dialect.supports_space_separated_column_options() {
|
||||
Ok(Some(ColumnOptions::SpaceSeparated(options)))
|
||||
} else {
|
||||
Ok(Some(ColumnOptions::CommaSeparated(options)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses a parenthesized comma-separated list of unqualified, possibly quoted identifiers.
|
||||
/// For example: `(col1, "col 2", ...)`
|
||||
pub fn parse_parenthesized_column_list(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue