This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new cf4ab7f9 Add support for `DROP MATERIALIZED VIEW` (#1743)
cf4ab7f9 is described below

commit cf4ab7f9ab031d168e10f8dbaaa3fa07f15acc63
Author: Ifeanyi Ubah <[email protected]>
AuthorDate: Thu Mar 13 20:51:29 2025 +0100

    Add support for `DROP MATERIALIZED VIEW` (#1743)
---
 src/ast/mod.rs            | 2 ++
 src/parser/mod.rs         | 4 +++-
 tests/sqlparser_common.rs | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 139850e8..4c0ffea9 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -6733,6 +6733,7 @@ impl fmt::Display for HavingBoundKind {
 pub enum ObjectType {
     Table,
     View,
+    MaterializedView,
     Index,
     Schema,
     Database,
@@ -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",
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index d3c48a6e..60e1c146 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -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) {
@@ -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(),
             );
         };
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index b5d42ea6..d0edafb7 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to