Skip to content

Commit 64c4a17

Browse files
iffyioayman-sigma
authored andcommitted
Add support for DROP MATERIALIZED VIEW (apache#1743)
1 parent 18774e5 commit 64c4a17

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/ast/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -6751,6 +6751,7 @@ impl fmt::Display for HavingBoundKind {
67516751
pub enum ObjectType {
67526752
Table,
67536753
View,
6754+
MaterializedView,
67546755
Index,
67556756
Schema,
67566757
Database,
@@ -6765,6 +6766,7 @@ impl fmt::Display for ObjectType {
67656766
f.write_str(match self {
67666767
ObjectType::Table => "TABLE",
67676768
ObjectType::View => "VIEW",
6769+
ObjectType::MaterializedView => "MATERIALIZED VIEW",
67686770
ObjectType::Index => "INDEX",
67696771
ObjectType::Schema => "SCHEMA",
67706772
ObjectType::Database => "DATABASE",

src/parser/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5816,6 +5816,8 @@ impl<'a> Parser<'a> {
58165816
ObjectType::Table
58175817
} else if self.parse_keyword(Keyword::VIEW) {
58185818
ObjectType::View
5819+
} else if self.parse_keywords(&[Keyword::MATERIALIZED, Keyword::VIEW]) {
5820+
ObjectType::MaterializedView
58195821
} else if self.parse_keyword(Keyword::INDEX) {
58205822
ObjectType::Index
58215823
} else if self.parse_keyword(Keyword::ROLE) {
@@ -5846,7 +5848,7 @@ impl<'a> Parser<'a> {
58465848
return self.parse_drop_extension();
58475849
} else {
58485850
return self.expected(
5849-
"CONNECTOR, DATABASE, EXTENSION, FUNCTION, INDEX, POLICY, PROCEDURE, ROLE, SCHEMA, SECRET, SEQUENCE, STAGE, TABLE, TRIGGER, TYPE, or VIEW after DROP",
5851+
"CONNECTOR, DATABASE, EXTENSION, FUNCTION, INDEX, POLICY, PROCEDURE, ROLE, SCHEMA, SECRET, SEQUENCE, STAGE, TABLE, TRIGGER, TYPE, VIEW, or MATERIALIZED VIEW after DROP",
58505852
self.peek_token(),
58515853
);
58525854
};

tests/sqlparser_common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8190,6 +8190,9 @@ fn parse_drop_view() {
81908190
}
81918191
_ => unreachable!(),
81928192
}
8193+
8194+
verified_stmt("DROP MATERIALIZED VIEW a.b.c");
8195+
verified_stmt("DROP MATERIALIZED VIEW IF EXISTS a.b.c");
81938196
}
81948197

81958198
#[test]

0 commit comments

Comments
 (0)