mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
Add SECURE keyword for views in Snowflake (#2004)
This commit is contained in:
parent
779dcf91f6
commit
cffff30961
6 changed files with 49 additions and 3 deletions
|
|
@ -3256,6 +3256,9 @@ pub enum Statement {
|
|||
or_alter: bool,
|
||||
or_replace: bool,
|
||||
materialized: bool,
|
||||
/// Snowflake: SECURE view modifier
|
||||
/// <https://docs.snowflake.com/en/sql-reference/sql/create-view#syntax>
|
||||
secure: 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.
|
||||
|
|
@ -5118,6 +5121,7 @@ impl fmt::Display for Statement {
|
|||
columns,
|
||||
query,
|
||||
materialized,
|
||||
secure,
|
||||
options,
|
||||
cluster_by,
|
||||
comment,
|
||||
|
|
@ -5139,7 +5143,7 @@ impl fmt::Display for Statement {
|
|||
}
|
||||
write!(
|
||||
f,
|
||||
"{materialized}{temporary}VIEW {if_not_and_name}{to}",
|
||||
"{secure}{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")
|
||||
|
|
@ -5149,6 +5153,7 @@ impl fmt::Display for Statement {
|
|||
} else {
|
||||
format!("{name}")
|
||||
},
|
||||
secure = if *secure { "SECURE " } else { "" },
|
||||
materialized = if *materialized { "MATERIALIZED " } else { "" },
|
||||
temporary = if *temporary { "TEMPORARY " } else { "" },
|
||||
to = to
|
||||
|
|
|
|||
|
|
@ -395,6 +395,7 @@ impl Spanned for Statement {
|
|||
or_alter: _,
|
||||
or_replace: _,
|
||||
materialized: _,
|
||||
secure: _,
|
||||
name,
|
||||
columns,
|
||||
query,
|
||||
|
|
|
|||
|
|
@ -833,6 +833,7 @@ define_keywords!(
|
|||
SECONDARY_ENGINE_ATTRIBUTE,
|
||||
SECONDS,
|
||||
SECRET,
|
||||
SECURE,
|
||||
SECURITY,
|
||||
SEED,
|
||||
SELECT,
|
||||
|
|
|
|||
|
|
@ -4732,8 +4732,11 @@ impl<'a> Parser<'a> {
|
|||
let create_view_params = self.parse_create_view_params()?;
|
||||
if self.parse_keyword(Keyword::TABLE) {
|
||||
self.parse_create_table(or_replace, temporary, global, transient)
|
||||
} else if self.parse_keyword(Keyword::MATERIALIZED) || self.parse_keyword(Keyword::VIEW) {
|
||||
self.prev_token();
|
||||
} else if self.peek_keyword(Keyword::MATERIALIZED)
|
||||
|| self.peek_keyword(Keyword::VIEW)
|
||||
|| self.peek_keywords(&[Keyword::SECURE, Keyword::MATERIALIZED, Keyword::VIEW])
|
||||
|| self.peek_keywords(&[Keyword::SECURE, Keyword::VIEW])
|
||||
{
|
||||
self.parse_create_view(or_alter, or_replace, temporary, create_view_params)
|
||||
} else if self.parse_keyword(Keyword::POLICY) {
|
||||
self.parse_create_policy()
|
||||
|
|
@ -5853,6 +5856,7 @@ impl<'a> Parser<'a> {
|
|||
temporary: bool,
|
||||
create_view_params: Option<CreateViewParams>,
|
||||
) -> Result<Statement, ParserError> {
|
||||
let secure = self.parse_keyword(Keyword::SECURE);
|
||||
let materialized = self.parse_keyword(Keyword::MATERIALIZED);
|
||||
self.expect_keyword_is(Keyword::VIEW)?;
|
||||
let allow_unquoted_hyphen = dialect_of!(self is BigQueryDialect);
|
||||
|
|
@ -5923,6 +5927,7 @@ impl<'a> Parser<'a> {
|
|||
columns,
|
||||
query,
|
||||
materialized,
|
||||
secure,
|
||||
or_replace,
|
||||
options,
|
||||
cluster_by,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue