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 a996790e7f5 Support Hive SHOW VIEWS & SHOW MATERIALIZED VIEWS & SHOW 
PARTITIONS statement parse (#36263)
a996790e7f5 is described below

commit a996790e7f518151adf56f844f04df71f2019db6
Author: Claire <[email protected]>
AuthorDate: Tue Aug 12 11:13:42 2025 +0800

    Support Hive SHOW VIEWS & SHOW MATERIALIZED VIEWS & SHOW PARTITIONS 
statement parse (#36263)
    
    * support show statement
    
    * Update DALStatement.g4
    
    * update release-notes
---
 RELEASE-NOTES.md                                   |  1 +
 .../src/main/antlr4/imports/hive/DALStatement.g4   | 21 +++++++++++-
 .../src/main/antlr4/imports/hive/HiveKeyword.g4    |  4 +++
 .../statement/type/HiveDALStatementVisitor.java    | 21 ++++++++++++
 .../show/HiveShowMaterializedViewsStatement.java   | 38 ++++++++++++++++++++++
 .../hive/dal/show/HiveShowPartitionsStatement.java | 38 ++++++++++++++++++++++
 .../hive/dal/show/HiveShowViewsStatement.java      | 38 ++++++++++++++++++++++
 .../it/parser/src/main/resources/case/dal/show.xml | 20 ++++++++++++
 .../src/main/resources/sql/supported/dal/show.xml  | 19 +++++++++++
 9 files changed, 199 insertions(+), 1 deletion(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 2a9c94d49a0..fb6024298eb 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -75,6 +75,7 @@
 1. SQL Parser: Support Hive DROP FUNCTION statement parse - 
[#36196](https://github.com/apache/shardingsphere/pull/36196)
 1. SQL Parser: Support Hive RELOAD FUNCTION statement parse - 
[#36200](https://github.com/apache/shardingsphere/pull/36200)
 1. SQL Parser: Support Hive SHOW DATABASES & SHOW CONNECTORS & SHOW TABLES 
statement parse - [#36221](https://github.com/apache/shardingsphere/pull/36221)
+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 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 14e3e9d1c36..e2c33e8a04e 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
@@ -17,12 +17,15 @@
 
 grammar DALStatement;
 
-import BaseRule;
+import BaseRule, DMLStatement;
 
 show
     : showDatabases
     | showConnectors
     | showTables
+    | showViews
+    | showMaterializedViews
+    | showPartitions
     ;
 
 showDatabases
@@ -37,6 +40,22 @@ showTables
     : SHOW TABLES (IN databaseName)? stringLiterals?
     ;
 
+showViews
+    : SHOW VIEWS showFrom? showLike?
+    ;
+
+showMaterializedViews
+    : SHOW MATERIALIZED VIEWS showFrom? showLike?
+    ;
+
+showPartitions
+    : SHOW PARTITIONS tableName partitionSpec? whereClause? orderByClause? 
limitClause?
+    ;
+
+showFrom
+    : (IN | FROM) databaseName
+    ;
+
 showLike
     : LIKE stringLiterals
     ;
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 f373cbe0750..2e55018e41b 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
@@ -2947,6 +2947,10 @@ VIEW
     : V I E W
     ;
 
+VIEWS
+    : V I E W S
+    ;
+
 VIRTUAL
     : V I R T U A L
     ;
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 e442ac2f145..3b2dfad34b6 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
@@ -25,6 +25,9 @@ import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowData
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowLikeContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowConnectorsContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowTablesContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowViewsContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowMaterializedViewsContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowPartitionsContext;
 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;
@@ -33,6 +36,9 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.Datab
 import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.StringLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowConnectorsStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowMaterializedViewsStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowPartitionsStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.hive.dal.show.HiveShowViewsStatement;
 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.table.MySQLShowTablesStatement;
@@ -93,4 +99,19 @@ public final class HiveDALStatementVisitor extends 
HiveStatementVisitor implemen
         result.addParameterMarkers(getParameterMarkerSegments());
         return result;
     }
+    
+    @Override
+    public ASTNode visitShowViews(final ShowViewsContext ctx) {
+        return new HiveShowViewsStatement(getDatabaseType());
+    }
+    
+    @Override
+    public ASTNode visitShowMaterializedViews(final 
ShowMaterializedViewsContext ctx) {
+        return new HiveShowMaterializedViewsStatement(getDatabaseType());
+    }
+    
+    @Override
+    public ASTNode visitShowPartitions(final ShowPartitionsContext ctx) {
+        return new HiveShowPartitionsStatement(getDatabaseType());
+    }
 }
diff --git 
a/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowMaterializedViewsStatement.java
 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowMaterializedViewsStatement.java
new file mode 100644
index 00000000000..e26a998446e
--- /dev/null
+++ 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowMaterializedViewsStatement.java
@@ -0,0 +1,38 @@
+/*
+ * 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.attribute.SQLStatementAttributes;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TablelessDataSourceBroadcastRouteSQLStatementAttribute;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
+
+/**
+ * Show materialized views statement for Hive.
+ */
+public final class HiveShowMaterializedViewsStatement extends DALStatement {
+    
+    public HiveShowMaterializedViewsStatement(final DatabaseType databaseType) 
{
+        super(databaseType);
+    }
+    
+    @Override
+    public SQLStatementAttributes getAttributes() {
+        return new SQLStatementAttributes(new 
TablelessDataSourceBroadcastRouteSQLStatementAttribute());
+    }
+}
diff --git 
a/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowPartitionsStatement.java
 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowPartitionsStatement.java
new file mode 100644
index 00000000000..d3b08838c65
--- /dev/null
+++ 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowPartitionsStatement.java
@@ -0,0 +1,38 @@
+/*
+ * 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.attribute.SQLStatementAttributes;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TablelessDataSourceBroadcastRouteSQLStatementAttribute;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
+
+/**
+ * Show partitions statement for Hive.
+ */
+public final class HiveShowPartitionsStatement extends DALStatement {
+    
+    public HiveShowPartitionsStatement(final DatabaseType databaseType) {
+        super(databaseType);
+    }
+    
+    @Override
+    public SQLStatementAttributes getAttributes() {
+        return new SQLStatementAttributes(new 
TablelessDataSourceBroadcastRouteSQLStatementAttribute());
+    }
+}
diff --git 
a/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowViewsStatement.java
 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowViewsStatement.java
new file mode 100644
index 00000000000..bc16355d8ce
--- /dev/null
+++ 
b/parser/sql/statement/type/hive/src/main/java/org/apache/shardingsphere/sql/parser/statement/hive/dal/show/HiveShowViewsStatement.java
@@ -0,0 +1,38 @@
+/*
+ * 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.attribute.SQLStatementAttributes;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TablelessDataSourceBroadcastRouteSQLStatementAttribute;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.DALStatement;
+
+/**
+ * Show views statement for Hive.
+ */
+public final class HiveShowViewsStatement extends DALStatement {
+    
+    public HiveShowViewsStatement(final DatabaseType databaseType) {
+        super(databaseType);
+    }
+    
+    @Override
+    public SQLStatementAttributes getAttributes() {
+        return new SQLStatementAttributes(new 
TablelessDataSourceBroadcastRouteSQLStatementAttribute());
+    }
+}
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 6df44dad3e8..f30b882e461 100644
--- a/test/it/parser/src/main/resources/case/dal/show.xml
+++ b/test/it/parser/src/main/resources/case/dal/show.xml
@@ -916,4 +916,24 @@
             <like pattern="order_*" start-delimiter="'" end-delimiter="'" 
start-index="24" stop-index="32" />
         </filter>
     </show-tables>
+
+    <show sql-case-id="show_views_basic" />
+    <show sql-case-id="show_views_with_like_wildcard" />
+    <show sql-case-id="show_views_from_database" />
+    <show sql-case-id="show_views_in_database" />
+    <show sql-case-id="show_views_in_db_with_like" />
+    <show sql-case-id="show_views_from_db_with_like" />
+    <show sql-case-id="show_materialized_views_basic" />
+    <show sql-case-id="show_materialized_views_with_like" />
+    <show sql-case-id="show_materialized_views_in_database" />
+    <show sql-case-id="show_materialized_views_from_database" />
+    <show sql-case-id="show_materialized_views_in_db_with_like" />
+    <show sql-case-id="show_materialized_views_from_db_with_like" />
+    <show sql-case-id="show_partitions_basic" />
+    <show sql-case-id="show_partitions_with_db" />
+    <show sql-case-id="show_partitions_with_partition_spec" />
+    <show sql-case-id="show_partitions_with_where" />
+    <show sql-case-id="show_partitions_with_order_by" />
+    <show sql-case-id="show_partitions_with_limit" />
+    <show sql-case-id="show_partitions_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 67767018b34..36e13d6af6b 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
@@ -156,4 +156,23 @@
     <sql-case id="show_tables_in_database" value="SHOW TABLES IN sales_db;" 
db-types="Hive" />
     <sql-case id="show_tables_with_wildcard" value="SHOW TABLES 'order_*';" 
db-types="Hive" />
     <sql-case id="show_tables_in_db_with_wildcard" value="SHOW TABLES IN 
sales_db 'order_*';" db-types="Hive" />
+    <sql-case id="show_views_basic" value="SHOW VIEWS;" db-types="Hive" />
+    <sql-case id="show_views_with_like_wildcard" value="SHOW VIEWS LIKE 
'user_*';" db-types="Hive" />
+    <sql-case id="show_views_from_database" value="SHOW VIEWS FROM 
analytics_db;" db-types="Hive" />
+    <sql-case id="show_views_in_database" value="SHOW VIEWS IN reports_db;" 
db-types="Hive" />
+    <sql-case id="show_views_in_db_with_like" value="SHOW VIEWS IN sales_db 
LIKE 'quarterly_*|annual_*';" db-types="Hive" />
+    <sql-case id="show_views_from_db_with_like" value="SHOW VIEWS FROM 
inventory_db LIKE 'low_stock_|out_of_stock';" db-types="Hive" />
+    <sql-case id="show_materialized_views_basic" value="SHOW MATERIALIZED 
VIEWS;" db-types="Hive" />
+    <sql-case id="show_materialized_views_with_like" value="SHOW MATERIALIZED 
VIEWS LIKE 'sales_*';" db-types="Hive" />
+    <sql-case id="show_materialized_views_in_database" value="SHOW 
MATERIALIZED VIEWS IN analytics_db;" db-types="Hive" />
+    <sql-case id="show_materialized_views_from_database" value="SHOW 
MATERIALIZED VIEWS FROM reports_db;" db-types="Hive" />
+    <sql-case id="show_materialized_views_in_db_with_like" value="SHOW 
MATERIALIZED VIEWS IN inventory_db LIKE 'stock_*|supply_*';" db-types="Hive" />
+    <sql-case id="show_materialized_views_from_db_with_like" value="SHOW 
MATERIALIZED VIEWS FROM orders_db LIKE 'daily_*|monthly_*';" db-types="Hive" />
+    <sql-case id="show_partitions_basic" value="SHOW PARTITIONS orders;" 
db-types="Hive" />
+    <sql-case id="show_partitions_with_db" value="SHOW PARTITIONS 
sales.orders;" db-types="Hive" />
+    <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_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-cases>

Reply via email to