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

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 405eafc21c6 fix:Support Hive DROP MATERIALIZED VIEW statement parse 
(#36145)
405eafc21c6 is described below

commit 405eafc21c6246799b0369890d11d460eac74a87
Author: Claire <[email protected]>
AuthorDate: Fri Aug 1 13:47:11 2025 +0800

    fix:Support Hive DROP MATERIALIZED VIEW statement parse (#36145)
    
    * support hive DROP MATERIALIZED VIEW statement
    
    * update RELEASE-NOTES.md
---
 RELEASE-NOTES.md                                            |  1 +
 .../hive/src/main/antlr4/imports/hive/DDLStatement.g4       |  4 ++++
 .../shardingsphere/sql/parser/autogen/HiveStatement.g4      |  1 +
 .../visitor/statement/type/HiveDDLStatementVisitor.java     | 13 ++++++++++---
 .../src/main/resources/case/ddl/drop-materialized-view.xml  |  2 ++
 .../resources/sql/supported/ddl/drop-materialized-view.xml  |  2 ++
 6 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 554ba7d3517..c681ee6d279 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -79,6 +79,7 @@
 1. SQL Parser: Support Hive DROP VIEW statement parse - 
[#36122](https://github.com/apache/shardingsphere/pull/36122)
 1. SQL Parser: Support Hive ALTER VIEW statement parse - 
[#36134](https://github.com/apache/shardingsphere/pull/36134)
 1. SQL Parser: Support Hive CREATE MATERIALIZED VIEW statement parse - 
[#36144](https://github.com/apache/shardingsphere/pull/36144)
+1. SQL Parser: Support Hive DROP MATERIALIZED VIEW statement parse - 
[#36145](https://github.com/apache/shardingsphere/pull/36145)
 1. SQL Parser: Support SQL Server xml methods parse - 
[#35911](https://github.com/apache/shardingsphere/pull/35911)
 1. SQL Parser: Support SQL Server CHANGETABLE function parse - 
[#35920](https://github.com/apache/shardingsphere/pull/35920)
 1. SQL Parser: Support SQL Server AI_GENERATE_EMBEDDINGS function parse - 
[#35922](https://github.com/apache/shardingsphere/pull/35922)
diff --git 
a/parser/sql/dialect/hive/src/main/antlr4/imports/hive/DDLStatement.g4 
b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/DDLStatement.g4
index 5ed45f89569..9ccbdcf5716 100644
--- a/parser/sql/dialect/hive/src/main/antlr4/imports/hive/DDLStatement.g4
+++ b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/DDLStatement.g4
@@ -96,6 +96,10 @@ createMaterializedView
     : CREATE MATERIALIZED VIEW ifNotExists? viewNameWithDb 
materializedViewOptions? AS select
     ;
 
+dropMaterializedView
+    : DROP MATERIALIZED VIEW viewNameWithDb
+    ;
+
 alterDatabaseSpecification_
     : SET DBPROPERTIES LP_ dbProperties RP_
     | SET OWNER (USER | ROLE) identifier
diff --git 
a/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
 
b/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
index 222c8ed7e86..e0dcb17f317 100644
--- 
a/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
+++ 
b/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
@@ -39,6 +39,7 @@ execute
     | dropView
     | alterView
     | createMaterializedView
+    | dropMaterializedView
     ) (SEMI_ EOF? | EOF)
     | EOF
     ;
diff --git 
a/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDDLStatementVisitor.java
 
b/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDDLStatementVisitor.java
index cb74c40b946..7f4ab18338a 100644
--- 
a/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDDLStatementVisitor.java
+++ 
b/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDDLStatementVisitor.java
@@ -40,6 +40,7 @@ import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.MsckStat
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ChangeColumnContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ColumnNameContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.CreateMaterializedViewContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DropMaterializedViewContext;
 import 
org.apache.shardingsphere.sql.parser.hive.visitor.statement.HiveStatementVisitor;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.column.ColumnDefinitionSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.constraint.ConstraintDefinitionSegment;
@@ -54,8 +55,11 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.ta
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.table.CreateTableStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.DropDatabaseStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.table.DropTableStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.CreateMaterializedViewStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.CreateViewStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.DropViewStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.AlterViewStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.CreateMaterializedViewStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.DropMaterializedViewStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.value.collection.CollectionValue;
 import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.TruncateStatement;
@@ -68,8 +72,6 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.column.al
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.column.alter.ReplaceColumnDefinitionSegment;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.CreateViewContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ViewNameWithDbContext;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.CreateViewStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.AlterViewStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.SelectStatement;
 import java.util.Collections;
 
@@ -339,4 +341,9 @@ public final class HiveDDLStatementVisitor extends 
HiveStatementVisitor implemen
     public ASTNode visitCreateMaterializedView(final 
CreateMaterializedViewContext ctx) {
         return new CreateMaterializedViewStatement(getDatabaseType());
     }
+    
+    @Override
+    public ASTNode visitDropMaterializedView(final DropMaterializedViewContext 
ctx) {
+        return new DropMaterializedViewStatement(getDatabaseType());
+    }
 }
diff --git 
a/test/it/parser/src/main/resources/case/ddl/drop-materialized-view.xml 
b/test/it/parser/src/main/resources/case/ddl/drop-materialized-view.xml
index 6dc87c27813..b52b32fbe5c 100644
--- a/test/it/parser/src/main/resources/case/ddl/drop-materialized-view.xml
+++ b/test/it/parser/src/main/resources/case/ddl/drop-materialized-view.xml
@@ -20,4 +20,6 @@
     <drop-materialized-view sql-case-id="drop_materialized_view" />
     <drop-materialized-view sql-case-id="drop_materialized_view_cascade" />
     <drop-materialized-view sql-case-id="drop_materialized_view_if_exists" />
+    <drop-materialized-view sql-case-id="drop_materialized_view_basic" />
+    <drop-materialized-view sql-case-id="drop_materialized_view_with_db" />
 </sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/ddl/drop-materialized-view.xml
 
b/test/it/parser/src/main/resources/sql/supported/ddl/drop-materialized-view.xml
index b1e016f4349..4f5e6ca96dc 100644
--- 
a/test/it/parser/src/main/resources/sql/supported/ddl/drop-materialized-view.xml
+++ 
b/test/it/parser/src/main/resources/sql/supported/ddl/drop-materialized-view.xml
@@ -19,4 +19,6 @@
     <sql-case id="drop_materialized_view" value="DROP MATERIALIZED VIEW 
tid_matview;" db-types="PostgreSQL, Oracle" />
     <sql-case id="drop_materialized_view_cascade" value="DROP MATERIALIZED 
VIEW tid_matview CASCADE;" db-types="PostgreSQL" />
     <sql-case id="drop_materialized_view_if_exists" value="DROP MATERIALIZED 
VIEW IF EXISTS tid_matview;" db-types="PostgreSQL" />
+    <sql-case id="drop_materialized_view_basic" value="DROP MATERIALIZED VIEW 
sales_mv" db-types="Hive" />
+    <sql-case id="drop_materialized_view_with_db" value="DROP MATERIALIZED 
VIEW db1.sales_mv" db-types="Hive" />
 </sql-cases>

Reply via email to