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 a1e5d844060 fix:Support Hive DROP TABLE statement parse (#36018)
a1e5d844060 is described below

commit a1e5d8440606c2311d19e235431c33d229f8427c
Author: Claire <[email protected]>
AuthorDate: Wed Jul 16 11:10:22 2025 +0800

    fix:Support Hive DROP TABLE statement parse (#36018)
    
    * support DROP TABLE statement
    
    * update RELEASE-NOTES
    
    * update RELEASE-NOTES
---
 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 +++++++++++++
 .../it/parser/src/main/resources/case/ddl/drop-table.xml | 16 ++++++++++++++++
 .../src/main/resources/sql/supported/ddl/drop-table.xml  |  4 ++++
 6 files changed, 39 insertions(+)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 1ce92063ef3..d01678f1d0d 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -59,6 +59,7 @@
 1. SQL Parser: Support Hive Loading files into tables statement parse - 
[#36001](https://github.com/apache/shardingsphere/pull/36001)
 1. Encrypt: Add support for NOT LIKE operator in encryption - 
[#35984](https://github.com/apache/shardingsphere/pull/35984)
 1. SQL Parser: Support Hive ALTER DATABASE statement parse - 
[#36008](https://github.com/apache/shardingsphere/pull/36008)
+1. SQL Parser: Support Hive DROP TABLE statement parse - 
[#36018](https://github.com/apache/shardingsphere/pull/36018)
 
 ### Bug Fixes
 
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 09f5e4b2b1e..b1f6ddac44e 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
@@ -31,6 +31,10 @@ alterDatabase
     : ALTER (DATABASE | SCHEMA) identifier alterDatabaseSpecification_*
     ;
 
+dropTable
+    : DROP TABLE ifExists? tableList (PURGE)?
+    ;
+
 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 bada4d07fa4..32b65aaf9c7 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
@@ -29,6 +29,7 @@ execute
     | createDatabase
     | dropDatabase
     | alterDatabase
+    | dropTable
     ) (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 42e228e72d9..2f1b4239da0 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
@@ -22,11 +22,15 @@ import org.apache.shardingsphere.sql.parser.api.ASTNode;
 import 
org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DDLStatementVisitor;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.CreateDatabaseContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DropDatabaseContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DropTableContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.AlterDatabaseContext;
 import 
org.apache.shardingsphere.sql.parser.hive.visitor.statement.HiveStatementVisitor;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.CreateDatabaseStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.DropDatabaseStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.AlterDatabaseStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.table.DropTableStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.value.collection.CollectionValue;
 import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
 
 /**
@@ -52,4 +56,13 @@ public final class HiveDDLStatementVisitor extends 
HiveStatementVisitor implemen
     public ASTNode visitAlterDatabase(final AlterDatabaseContext ctx) {
         return new AlterDatabaseStatement(getDatabaseType());
     }
+    
+    @SuppressWarnings("unchecked")
+    @Override
+    public ASTNode visitDropTable(final DropTableContext ctx) {
+        DropTableStatement result = new DropTableStatement(getDatabaseType());
+        result.setIfExists(null != ctx.ifExists());
+        result.getTables().addAll(((CollectionValue<SimpleTableSegment>) 
visit(ctx.tableList())).getValue());
+        return result;
+    }
 }
diff --git a/test/it/parser/src/main/resources/case/ddl/drop-table.xml 
b/test/it/parser/src/main/resources/case/ddl/drop-table.xml
index e53f7426e1a..1ff20cc1c8e 100644
--- a/test/it/parser/src/main/resources/case/ddl/drop-table.xml
+++ b/test/it/parser/src/main/resources/case/ddl/drop-table.xml
@@ -79,4 +79,20 @@
     <drop-table sql-case-id="drop_bit_xor_table">
         <table name="BIT_XOR" start-index="11" stop-index="17" />
     </drop-table>
+
+    <drop-table sql-case-id="drop_table_hive">
+        <table name="t_log" start-index="11" stop-index="15" />
+    </drop-table>
+
+    <drop-table sql-case-id="drop_table_if_exists_hive">
+        <table name="t_log" start-index="21" stop-index="25" />
+    </drop-table>
+
+    <drop-table sql-case-id="drop_table_purge_hive">
+        <table name="t_log" start-index="11" stop-index="15" />
+    </drop-table>
+
+    <drop-table sql-case-id="drop_table_if_exists_purge_hive">
+        <table name="t_log" start-index="21" stop-index="25" />
+    </drop-table>
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/drop-table.xml 
b/test/it/parser/src/main/resources/sql/supported/ddl/drop-table.xml
index 95110efb833..1c48665b2dc 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/drop-table.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/drop-table.xml
@@ -33,4 +33,8 @@
     <sql-case id="drop_table_with_double_quota" value="DROP TABLE 
&quot;t_order&quot;" db-types="PostgreSQL,openGauss" />
     <sql-case id="drop_table_with_bracket" value="DROP TABLE [t_order]" 
db-types="SQLServer" />
     <sql-case id="drop_bit_xor_table" value="drop table BIT_XOR" 
db-types="MySQL" />
+    <sql-case id="drop_table_hive" value="DROP TABLE t_log" />
+    <sql-case id="drop_table_if_exists_hive" value="DROP TABLE IF EXISTS 
t_log" db-types="Hive" />
+    <sql-case id="drop_table_purge_hive" value="DROP TABLE t_log PURGE" 
db-types="Hive" />
+    <sql-case id="drop_table_if_exists_purge_hive" value="DROP TABLE IF EXISTS 
t_log PURGE" db-types="Hive" />
 </sql-cases>

Reply via email to