Skip to content

Add support for DROP MATERIALIZED VIEW #1743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6733,6 +6733,7 @@ impl fmt::Display for HavingBoundKind {
pub enum ObjectType {
Table,
View,
MaterializedView,
Index,
Schema,
Database,
Expand All @@ -6747,6 +6748,7 @@ impl fmt::Display for ObjectType {
f.write_str(match self {
ObjectType::Table => "TABLE",
ObjectType::View => "VIEW",
ObjectType::MaterializedView => "MATERIALIZED VIEW",
ObjectType::Index => "INDEX",
ObjectType::Schema => "SCHEMA",
ObjectType::Database => "DATABASE",
Expand Down
4 changes: 3 additions & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5806,6 +5806,8 @@ impl<'a> Parser<'a> {
ObjectType::Table
} else if self.parse_keyword(Keyword::VIEW) {
ObjectType::View
} else if self.parse_keywords(&[Keyword::MATERIALIZED, Keyword::VIEW]) {
ObjectType::MaterializedView
} else if self.parse_keyword(Keyword::INDEX) {
ObjectType::Index
} else if self.parse_keyword(Keyword::ROLE) {
Expand Down Expand Up @@ -5836,7 +5838,7 @@ impl<'a> Parser<'a> {
return self.parse_drop_extension();
} else {
return self.expected(
"CONNECTOR, DATABASE, EXTENSION, FUNCTION, INDEX, POLICY, PROCEDURE, ROLE, SCHEMA, SECRET, SEQUENCE, STAGE, TABLE, TRIGGER, TYPE, or VIEW after DROP",
"CONNECTOR, DATABASE, EXTENSION, FUNCTION, INDEX, POLICY, PROCEDURE, ROLE, SCHEMA, SECRET, SEQUENCE, STAGE, TABLE, TRIGGER, TYPE, VIEW, or MATERIALIZED VIEW after DROP",
self.peek_token(),
);
};
Expand Down
3 changes: 3 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8189,6 +8189,9 @@ fn parse_drop_view() {
}
_ => unreachable!(),
}

verified_stmt("DROP MATERIALIZED VIEW a.b.c");
verified_stmt("DROP MATERIALIZED VIEW IF EXISTS a.b.c");
}

#[test]
Expand Down