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 ccd0e90a7ac Support Hive SHOW TRANSACTIONS & SHOW COMPACTIONS 
statement parse (#36301)
ccd0e90a7ac is described below

commit ccd0e90a7acaf316912eec7f40fb5383f80354c8
Author: Claire <[email protected]>
AuthorDate: Thu Aug 14 16:55:21 2025 +0800

    Support Hive SHOW TRANSACTIONS & SHOW COMPACTIONS statement parse (#36301)
    
    * support show transactions
    
    * support show compactions
    
    * update release-notes
    
    * update
---
 RELEASE-NOTES.md                                   |  1 +
 .../src/main/antlr4/imports/hive/DALStatement.g4   | 12 +++++++++
 .../src/main/antlr4/imports/hive/HiveKeyword.g4    | 16 +++++++++++
 .../statement/type/HiveDALStatementVisitor.java    | 14 ++++++++++
 .../dal/show/HiveShowCompactionsStatement.java     | 31 ++++++++++++++++++++++
 .../dal/show/HiveShowTransactionsStatement.java    | 31 ++++++++++++++++++++++
 .../it/parser/src/main/resources/case/dal/show.xml | 13 +++++++++
 .../src/main/resources/sql/supported/dal/show.xml  | 15 ++++++++++-
 8 files changed, 132 insertions(+), 1 deletion(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index e7da92b024e..12c9aa4f48f 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -79,6 +79,7 @@
 1. SQL Parser: Support Hive SHOW TABLE EXTENDED & SHOW TBLPROPERTIES & SHOW 
CREATE TABLE statement parse - 
[#36265](https://github.com/apache/shardingsphere/pull/36265)
 1. SQL Parser: Support Hive SHOW INDEX & SHOW COLUMNS & SHOW FUNCTIONS 
statement parse - [#36284](https://github.com/apache/shardingsphere/pull/36284)
 1. SQL Parser: Support Hive Show Granted Roles and Privileges & SHOW LOCKS & 
SHOW CONF statement parse - 
[#36300](https://github.com/apache/shardingsphere/pull/36300)
+1. SQL Parser: Support Hive SHOW TRANSACTIONS & SHOW COMPACTIONS statement 
parse - [#36301](https://github.com/apache/shardingsphere/pull/36301)
 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/DALStatement.g4 
b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4
index f80503058a2..16102107496 100644
--- a/parser/sql/dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4
+++ b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4
@@ -35,6 +35,8 @@ show
     | showGrantedRolesAndPrivileges
     | showLocks
     | showConf
+    | showTransactions
+    | showCompactions
     ;
 
 showDatabases
@@ -106,6 +108,16 @@ showConf
     : SHOW CONF configurationName
     ;
 
+showTransactions
+    : SHOW TRANSACTIONS
+    ;
+
+showCompactions
+    : SHOW COMPACTIONS (DATABASE | SCHEMA) databaseName
+    | SHOW COMPACTIONS tableName? partitionSpec? (POOL stringLiterals)? (TYPE 
stringLiterals)? (STATE stringLiterals)? orderByClause? limitClause?
+    | SHOW COMPACTIONS COMPACTIONID EQ_ NUMBER_
+    ;
+
 showFrom
     : (IN | FROM) databaseName
     ;
diff --git 
a/parser/sql/dialect/hive/src/main/antlr4/imports/hive/HiveKeyword.g4 
b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/HiveKeyword.g4
index eb005ff71ea..d250c8aad8f 100644
--- a/parser/sql/dialect/hive/src/main/antlr4/imports/hive/HiveKeyword.g4
+++ b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/HiveKeyword.g4
@@ -3389,3 +3389,19 @@ PRINCIPALS
 CONF
     : C O N F
     ;
+
+TRANSACTIONS
+    : T R A N S A C T I O N S
+    ;
+
+COMPACTIONS
+    : C O M P A C T I O N S
+    ;
+
+STATE
+    : S T A T E
+    ;
+
+COMPACTIONID
+    : C O M P A C T I O N I D
+    ;
diff --git 
a/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDALStatementVisitor.java
 
b/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDALStatementVisitor.java
index ae96b7ef65e..707f69948de 100644
--- 
a/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDALStatementVisitor.java
+++ 
b/parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/type/HiveDALStatementVisitor.java
@@ -37,6 +37,8 @@ import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowFunc
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowGrantedRolesAndPrivilegesContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowLocksContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowConfContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowTransactionsContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowCompactionsContext;
 import 
org.apache.shardingsphere.sql.parser.hive.visitor.statement.HiveStatementVisitor;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
@@ -54,6 +56,8 @@ import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowTblp
 import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowFunctionsStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowLocksStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowConfStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowTransactionsStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowCompactionsStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.mysql.dal.MySQLUseStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.database.MySQLShowDatabasesStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.privilege.MySQLShowGrantsStatement;
@@ -201,4 +205,14 @@ public final class HiveDALStatementVisitor extends 
HiveStatementVisitor implemen
     public ASTNode visitShowConf(final ShowConfContext ctx) {
         return new HiveShowConfStatement(getDatabaseType());
     }
+    
+    @Override
+    public ASTNode visitShowTransactions(final ShowTransactionsContext ctx) {
+        return new HiveShowTransactionsStatement(getDatabaseType());
+    }
+    
+    @Override
+    public ASTNode visitShowCompactions(final ShowCompactionsContext ctx) {
+        return new HiveShowCompactionsStatement(getDatabaseType());
+    }
 }
diff --git 
a/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowCompactionsStatement.java
 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowCompactionsStatement.java
new file mode 100644
index 00000000000..f265096f496
--- /dev/null
+++ 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowCompactionsStatement.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.statement.hive.dal.show;
+
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
+
+/**
+ * Show compactions extended statement for Hive.
+ */
+public final class HiveShowCompactionsStatement extends DALStatement {
+    
+    public HiveShowCompactionsStatement(final DatabaseType databaseType) {
+        super(databaseType);
+    }
+}
diff --git 
a/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowTransactionsStatement.java
 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowTransactionsStatement.java
new file mode 100644
index 00000000000..5bfedf34005
--- /dev/null
+++ 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowTransactionsStatement.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.statement.hive.dal.show;
+
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
+
+/**
+ * Show transactions extended statement for Hive.
+ */
+public final class HiveShowTransactionsStatement extends DALStatement {
+    
+    public HiveShowTransactionsStatement(final DatabaseType databaseType) {
+        super(databaseType);
+    }
+}
diff --git a/test/it/parser/src/main/resources/case/dal/show.xml 
b/test/it/parser/src/main/resources/case/dal/show.xml
index 9d2418bc7c9..158f7b6b9a7 100644
--- a/test/it/parser/src/main/resources/case/dal/show.xml
+++ b/test/it/parser/src/main/resources/case/dal/show.xml
@@ -1085,4 +1085,17 @@
     <show sql-case-id="show_locks_database" />
     <show sql-case-id="show_locks_schema" />
     <show sql-case-id="show_conf" />
+    <show sql-case-id="show_transactions" />
+    <show sql-case-id="show_compactions_basic" />
+    <show sql-case-id="show_compactions_with_database" />
+    <show sql-case-id="show_compactions_with_schema" />
+    <show sql-case-id="show_compactions_with_table" />
+    <show sql-case-id="show_compactions_with_partition" />
+    <show sql-case-id="show_compactions_with_type" />
+    <show sql-case-id="show_compactions_with_pool" />
+    <show sql-case-id="show_compactions_with_state" />
+    <show sql-case-id="show_compactions_with_order" />
+    <show sql-case-id="show_compactions_with_limit" />
+    <show sql-case-id="show_compactions_with_compaction_ID" />
+    <show sql-case-id="show_compactions_all_options" />
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dal/show.xml 
b/test/it/parser/src/main/resources/sql/supported/dal/show.xml
index a39707cf7e7..0ebdfa0697b 100644
--- a/test/it/parser/src/main/resources/sql/supported/dal/show.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dal/show.xml
@@ -173,7 +173,7 @@
     <sql-case id="show_partitions_with_partition_spec" value="SHOW PARTITIONS 
access_logs PARTITION(year='2023');" db-types="Hive" />
     <sql-case id="show_partitions_with_where" value="SHOW PARTITIONS products 
WHERE month >= 6;" db-types="Hive" />
     <sql-case id="show_partitions_with_order_by" value="SHOW PARTITIONS 
user_activity ORDER BY day DESC;" db-types="Hive" />
-    <sql-case id="show_partitions_with_limit" value="SHOW PARTITIONS 
transactions LIMIT 50;" db-types="Hive" />
+    <sql-case id="show_partitions_with_limit" value="SHOW PARTITIONS sales 
LIMIT 50;" db-types="Hive" />
     <sql-case id="show_partitions_all_options" value="SHOW PARTITIONS 
retail.sales PARTITION(region='north') WHERE quarter=4 AND revenue > 50000 
ORDER BY revenue DESC LIMIT 20;" db-types="Hive" />
     <sql-case id="show_table_extended_basic" value="SHOW TABLE EXTENDED LIKE 
'order_*';" db-types="Hive" />
     <sql-case id="show_table_extended_in_database" value="SHOW TABLE EXTENDED 
IN sales_db LIKE 'order_*';" db-types="Hive" />
@@ -222,4 +222,17 @@
     <sql-case id="show_locks_database" value="SHOW LOCKS DATABASE sales_db;" 
db-types="Hive" />
     <sql-case id="show_locks_schema" value="SHOW LOCKS SCHEMA sales_db;" 
db-types="Hive" />
     <sql-case id="show_conf" value="SHOW CONF 'hive.exec.dynamic.partition';" 
db-types="Hive" />
+    <sql-case id="show_transactions" value="SHOW TRANSACTIONS;" 
db-types="Hive" />
+    <sql-case id="show_compactions_basic" value="SHOW COMPACTIONS;" 
db-types="Hive" />
+    <sql-case id="show_compactions_with_database" value="SHOW COMPACTIONS 
DATABASE db1;" db-types="Hive" />
+    <sql-case id="show_compactions_with_schema" value="SHOW COMPACTIONS SCHEMA 
db1;" db-types="Hive" />
+    <sql-case id="show_compactions_with_table" value="SHOW COMPACTIONS tbl0;" 
db-types="Hive" />
+    <sql-case id="show_compactions_with_partition" value="SHOW COMPACTIONS 
tbl0 PARTITION (p=101, day='Monday');" db-types="Hive" />
+    <sql-case id="show_compactions_with_type" value="SHOW COMPACTIONS TYPE 
'minor';" db-types="Hive" />
+    <sql-case id="show_compactions_with_pool" value="SHOW COMPACTIONS POOL 
'pool0';" db-types="Hive" />
+    <sql-case id="show_compactions_with_state" value="SHOW COMPACTIONS STATE 
'working';" db-types="Hive" />
+    <sql-case id="show_compactions_with_order" value="SHOW COMPACTIONS ORDER 
BY `start` DESC;" db-types="Hive" />
+    <sql-case id="show_compactions_with_limit" value="SHOW COMPACTIONS LIMIT 
10;" db-types="Hive" />
+    <sql-case id="show_compactions_with_compaction_ID" value="SHOW COMPACTIONS 
compactionid=1;" db-types="Hive" />
+    <sql-case id="show_compactions_all_options" value="SHOW COMPACTIONS 
db1.tbl0 PARTITION (p=101, day='Monday') POOL 'pool0' TYPE 'minor' STATE 'ready 
for cleaning' ORDER BY `start` DESC LIMIT 5;" db-types="Hive" />
 </sql-cases>

Reply via email to