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 cda16feb64f Support Hive Show Granted Roles and Privileges & SHOW
LOCKS & SHOW CONF statement parse (#36300)
cda16feb64f is described below
commit cda16feb64f84d93e81f89780a2ce6361e60f604
Author: Claire <[email protected]>
AuthorDate: Thu Aug 14 14:06:21 2025 +0800
Support Hive Show Granted Roles and Privileges & SHOW LOCKS & SHOW CONF
statement parse (#36300)
* support show granted roles and privileges
* support show locks
* support show conf
* update
* update release-notes
---
RELEASE-NOTES.md | 1 +
.../hive/src/main/antlr4/imports/hive/BaseRule.g4 | 4 +++
.../src/main/antlr4/imports/hive/DALStatement.g4 | 23 ++++++++++++++++
.../src/main/antlr4/imports/hive/HiveKeyword.g4 | 12 +++++++++
.../statement/type/HiveDALStatementVisitor.java | 21 +++++++++++++++
.../hive/dal/show/HiveShowConfStatement.java | 31 ++++++++++++++++++++++
.../hive/dal/show/HiveShowLocksStatement.java | 31 ++++++++++++++++++++++
.../it/parser/src/main/resources/case/dal/show.xml | 12 +++++++++
.../src/main/resources/sql/supported/dal/show.xml | 12 +++++++++
9 files changed, 147 insertions(+)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 136ff82d387..e7da92b024e 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -78,6 +78,7 @@
1. SQL Parser: Support Hive SHOW VIEWS & SHOW MATERIALIZED VIEWS & SHOW
PARTITIONS statement parse -
[#36263](https://github.com/apache/shardingsphere/pull/36263)
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 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/BaseRule.g4
b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4
index 788eadac598..847eee1bff4 100644
--- a/parser/sql/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4
+++ b/parser/sql/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4
@@ -660,6 +660,10 @@ macroName
: identifier
;
+configurationName
+ : string_
+ ;
+
oldColumn
: columnName
;
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 4cc58c10d61..f80503058a2 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
@@ -32,6 +32,9 @@ show
| showIndex
| showColumns
| showFunctions
+ | showGrantedRolesAndPrivileges
+ | showLocks
+ | showConf
;
showDatabases
@@ -83,6 +86,26 @@ showFunctions
: SHOW FUNCTIONS showLike?
;
+showGrantedRolesAndPrivileges
+ : SHOW ROLE GRANT
+ | SHOW GRANT
+ | SHOW CURRENT ROLES
+ | SHOW ROLES
+ | SHOW PRINCIPALS
+ ;
+
+showLocks
+ : SHOW LOCKS tableName
+ | SHOW LOCKS tableName EXTENDED
+ | SHOW LOCKS tableName partitionSpec
+ | SHOW LOCKS tableName partitionSpec EXTENDED
+ | SHOW LOCKS (DATABASE | SCHEMA) databaseName
+ ;
+
+showConf
+ : SHOW CONF configurationName
+ ;
+
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 9e442363af5..eb005ff71ea 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
@@ -2183,6 +2183,10 @@ ROLE
: R O L E
;
+ROLES
+ : R O L E S
+ ;
+
ROLLBACK
: R O L L B A C K
;
@@ -3377,3 +3381,11 @@ CONNECTORS
FORMATTED
: F O R M A T T E D
;
+
+PRINCIPALS
+ : P R I N C I P A L S
+ ;
+
+CONF
+ : C O N F
+ ;
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 20ad0e896d0..ae96b7ef65e 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
@@ -34,6 +34,9 @@ import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowCrea
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowIndexContext;
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowColumnsContext;
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowFunctionsContext;
+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.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;
@@ -49,8 +52,11 @@ import
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowView
import
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowTablesExtendedStatement;
import
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowTblpropertiesStatement;
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.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;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.table.MySQLShowCreateTableStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.table.MySQLShowTablesStatement;
import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.index.MySQLShowIndexStatement;
@@ -180,4 +186,19 @@ public final class HiveDALStatementVisitor extends
HiveStatementVisitor implemen
public ASTNode visitShowFunctions(final ShowFunctionsContext ctx) {
return new HiveShowFunctionsStatement(getDatabaseType());
}
+
+ @Override
+ public ASTNode visitShowGrantedRolesAndPrivileges(final
ShowGrantedRolesAndPrivilegesContext ctx) {
+ return new MySQLShowGrantsStatement(getDatabaseType());
+ }
+
+ @Override
+ public ASTNode visitShowLocks(final ShowLocksContext ctx) {
+ return new HiveShowLocksStatement(getDatabaseType());
+ }
+
+ @Override
+ public ASTNode visitShowConf(final ShowConfContext ctx) {
+ return new HiveShowConfStatement(getDatabaseType());
+ }
}
diff --git
a/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowConfStatement.java
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowConfStatement.java
new file mode 100644
index 00000000000..ac1e1c363fc
--- /dev/null
+++
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowConfStatement.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 conf extended statement for Hive.
+ */
+public final class HiveShowConfStatement extends DALStatement {
+
+ public HiveShowConfStatement(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/HiveShowLocksStatement.java
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowLocksStatement.java
new file mode 100644
index 00000000000..e244521549b
--- /dev/null
+++
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowLocksStatement.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 locks extended statement for Hive.
+ */
+public final class HiveShowLocksStatement extends DALStatement {
+
+ public HiveShowLocksStatement(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 3755c142d4c..9d2418bc7c9 100644
--- a/test/it/parser/src/main/resources/case/dal/show.xml
+++ b/test/it/parser/src/main/resources/case/dal/show.xml
@@ -1073,4 +1073,16 @@
<show sql-case-id="show_functions_basic" />
<show sql-case-id="show_functions_with_like" />
+ <show sql-case-id="show_role_grant_basic" />
+ <show sql-case-id="show_grant_basic" />
+ <show sql-case-id="show_current_roles" />
+ <show sql-case-id="show_roles_basic" />
+ <show sql-case-id="show_principals_basic" />
+ <show sql-case-id="show_locks_basic" />
+ <show sql-case-id="show_locks_extended" />
+ <show sql-case-id="show_locks_partition" />
+ <show sql-case-id="show_locks_partition_extended" />
+ <show sql-case-id="show_locks_database" />
+ <show sql-case-id="show_locks_schema" />
+ <show sql-case-id="show_conf" />
</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 960189f6f49..a39707cf7e7 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
@@ -210,4 +210,16 @@
<sql-case id="show_columns_db_like_from" value="SHOW COLUMNS FROM
inventory FROM warehouse_db LIKE 'stock_*|quantity';" db-types="Hive" />
<sql-case id="show_functions_basic" value="SHOW FUNCTIONS;"
db-types="Hive" />
<sql-case id="show_functions_with_like" value="SHOW FUNCTIONS LIKE
'concat*';" db-types="Hive" />
+ <sql-case id="show_role_grant_basic" value="SHOW ROLE GRANT;"
db-types="Hive" />
+ <sql-case id="show_grant_basic" value="SHOW GRANT;" db-types="Hive" />
+ <sql-case id="show_current_roles" value="SHOW CURRENT ROLES;"
db-types="Hive" />
+ <sql-case id="show_roles_basic" value="SHOW ROLES;" db-types="Hive" />
+ <sql-case id="show_principals_basic" value="SHOW PRINCIPALS;"
db-types="Hive" />
+ <sql-case id="show_locks_basic" value="SHOW LOCKS orders;" db-types="Hive"
/>
+ <sql-case id="show_locks_extended" value="SHOW LOCKS orders EXTENDED;"
db-types="Hive" />
+ <sql-case id="show_locks_partition" value="SHOW LOCKS orders
PARTITION(dt='2024-08-01');" db-types="Hive" />
+ <sql-case id="show_locks_partition_extended" value="SHOW LOCKS orders
PARTITION(dt='2024-08-01') EXTENDED;" db-types="Hive" />
+ <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-cases>