Skip to content

Commit 46ce27f

Browse files
committed
SGA-11419 Skipping dialect methods and adding a comment on name if not exists supported by snowflake
1 parent 26f2680 commit 46ce27f

File tree

7 files changed

+6
-61
lines changed

7 files changed

+6
-61
lines changed

src/dialect/bigquery.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ impl Dialect for BigQueryDialect {
116116
true
117117
}
118118

119-
// See https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#:~:text=CREATE%20%5B%20OR%20REPLACE%20%5D%20VIEW%20%5B%20IF%20NOT%20EXISTS%20%5D
120-
fn create_view_if_not_exists_supported(&self) -> bool {
121-
true
122-
}
123-
124119
fn require_interval_qualifier(&self) -> bool {
125120
true
126121
}

src/dialect/generic.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ impl Dialect for GenericDialect {
8888
true
8989
}
9090

91-
fn create_view_if_not_exists_supported(&self) -> bool {
92-
true
93-
}
94-
95-
fn create_view_name_before_if_not_exists_supported(&self) -> bool {
96-
true
97-
}
98-
9991
fn support_map_literal_syntax(&self) -> bool {
10092
true
10193
}

src/dialect/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,6 @@ pub trait Dialect: Debug + Any {
247247
false
248248
}
249249

250-
/// Does the dialect support sql statements such as:
251-
/// CREATE VIEW IF NOT EXISTS view_name AS SELECT * FROM table_name
252-
fn create_view_if_not_exists_supported(&self) -> bool {
253-
false
254-
}
255-
256-
/// Does the dialect support view_name before IF NOT EXISTS in CREATE VIEW:
257-
/// CREATE VIEW IF NOT EXISTS view_name AS SELECT * FROM table_name
258-
fn create_view_name_before_if_not_exists_supported(&self) -> bool {
259-
false
260-
}
261-
262250
/// Returns true if the dialect supports referencing another named window
263251
/// within a window clause declaration.
264252
///

src/dialect/snowflake.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,6 @@ impl Dialect for SnowflakeDialect {
285285
true
286286
}
287287

288-
// See https://docs.snowflake.com/en/sql-reference/sql/create-view
289-
fn create_view_if_not_exists_supported(&self) -> bool {
290-
true
291-
}
292-
293-
// Snowflake allows table name before if not exists in CREATE VIEW
294-
fn create_view_name_before_if_not_exists_supported(&self) -> bool {
295-
true
296-
}
297-
298288
fn supports_left_associative_joins_without_parens(&self) -> bool {
299289
false
300290
}

src/dialect/sqlite.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ impl Dialect for SQLiteDialect {
5757
true
5858
}
5959

60-
// See https://www.sqlite.org/lang_createview.html
61-
fn create_view_if_not_exists_supported(&self) -> bool {
62-
true
63-
}
64-
6560
fn supports_start_transaction_modifier(&self) -> bool {
6661
true
6762
}

src/parser/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5774,18 +5774,13 @@ impl<'a> Parser<'a> {
57745774
let mut name_before_not_exists = false;
57755775
if self.peek_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]) {
57765776
// Possible syntax -> ... IF NOT EXISTS <name>
5777-
if self.dialect.create_view_if_not_exists_supported() {
5778-
if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
5779-
}
5777+
if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
57805778
name = self.parse_object_name(allow_unquoted_hyphen)?;
57815779
} else {
57825780
// Possible syntax -> ... <name> IF NOT EXISTS
5781+
// Supported by snowflake but is undocumented
57835782
name = self.parse_object_name(allow_unquoted_hyphen)?;
5784-
if self
5785-
.dialect
5786-
.create_view_name_before_if_not_exists_supported()
5787-
&& self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS])
5788-
{
5783+
if self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]) {
57895784
if_not_exists = true;
57905785
name_before_not_exists = true;
57915786
}

tests/sqlparser_common.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16387,18 +16387,8 @@ fn parse_drop_stream() {
1638716387

1638816388
#[test]
1638916389
fn parse_create_view_if_not_exists() {
16390-
let sql = "CREATE VIEW IF NOT EXISTS v AS SELECT 1";
16391-
let dialects = TestedDialects::new(vec![
16392-
Box::new(SnowflakeDialect {}),
16393-
Box::new(GenericDialect {}),
16394-
Box::new(SQLiteDialect {}),
16395-
Box::new(BigQueryDialect {}),
16396-
]);
16397-
let _ = dialects.verified_stmt(sql);
16390+
let sql: &'static str = "CREATE VIEW IF NOT EXISTS v AS SELECT 1";
16391+
let _ = all_dialects().verified_stmt(sql);
1639816392
let sql = "CREATE VIEW v IF NOT EXISTS AS SELECT 1";
16399-
let dialects = TestedDialects::new(vec![
16400-
Box::new(SnowflakeDialect {}),
16401-
Box::new(GenericDialect {}),
16402-
]);
16403-
let _ = dialects.verified_stmt(sql);
16393+
let _ = all_dialects().verified_stmt(sql);
1640416394
}

0 commit comments

Comments
 (0)