You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2025/08/08 06:58:44 UTC
(shardingsphere) branch master updated: fix:Support Hive RELOAD FUNCTION statement parse (#36200)
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 56c6504e74f fix:Support Hive RELOAD FUNCTION statement parse (#36200)
56c6504e74f is described below
commit 56c6504e74f3e90fb26ac12bb1dd270815914620
Author: Claire <cl...@163.com>
AuthorDate: Fri Aug 8 14:58:38 2025 +0800
fix:Support Hive RELOAD FUNCTION statement parse (#36200)
* support reload statement
* update release-notes
* Update ReloadFunctionStatementTestCase.java
add javadoc
* Update ReloadFunctionStatement.java
add javadoc
---
RELEASE-NOTES.md | 1 +
.../src/main/antlr4/imports/hive/DDLStatement.g4 | 4 ++
.../src/main/antlr4/imports/hive/HiveKeyword.g4 | 4 ++
.../sql/parser/autogen/HiveStatement.g4 | 1 +
.../statement/type/HiveDDLStatementVisitor.java | 7 ++++
.../core/database/visitor/SQLVisitorRule.java | 2 +
.../ddl/function/ReloadFunctionStatement.java} | 46 ++++++----------------
.../cases/parser/jaxb/RootSQLParserTestCases.java | 4 ++
.../function/ReloadFunctionStatementTestCase.java | 41 ++++---------------
.../main/resources/case/ddl/reload-function.xml | 22 +++++++++++
.../sql/supported/ddl/reload-function.xml | 22 +++++++++++
11 files changed, 86 insertions(+), 68 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index a6e7745cb4d..60b20c49302 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -73,6 +73,7 @@
1. SQL Parser: Support Hive DROP MACRO statement parse - [#36187](https://github.com/apache/shardingsphere/pull/36187)
1. SQL Parser: Support Hive CREATE FUNCTION statement parse - [#36193](https://github.com/apache/shardingsphere/pull/36193)
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 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 6afb7a8a9fc..acf2eda6c46 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
@@ -134,6 +134,10 @@ dropFunction
| DROP FUNCTION ifExists? functionName
;
+reloadFunction
+ : RELOAD (FUNCTIONS | FUNCTION)
+ ;
+
alterDatabaseSpecification_
: SET DBPROPERTIES LP_ dbProperties RP_
| SET OWNER (USER | ROLE) identifier
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 e3f25887ae3..3b13d2cd825 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
@@ -863,6 +863,10 @@ FUNCTION
: F U N C T I O N
;
+FUNCTIONS
+ : F U N C T I O N S
+ ;
+
GENERAL
: G E N E R A L
;
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 0302be3c669..6175cadc325 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
@@ -48,6 +48,7 @@ execute
| dropMacro
| createFunction
| dropFunction
+ | reloadFunction
) (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 b4e7aa1020a..f5d603f8497 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
@@ -49,6 +49,7 @@ import org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.CreateMa
import org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DropMacroContext;
import org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.CreateFunctionContext;
import org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DropFunctionContext;
+import org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ReloadFunctionContext;
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;
@@ -61,6 +62,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.AlterDatabaseStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.CreateDatabaseStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.function.ReloadFunctionStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.CreateIndexStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.DropIndexStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.AlterIndexStatement;
@@ -425,4 +427,9 @@ public final class HiveDDLStatementVisitor extends HiveStatementVisitor implemen
public ASTNode visitDropFunction(final DropFunctionContext ctx) {
return new DropFunctionStatement(getDatabaseType());
}
+
+ @Override
+ public ASTNode visitReloadFunction(final ReloadFunctionContext ctx) {
+ return new ReloadFunctionStatement(getDatabaseType());
+ }
}
diff --git a/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java b/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
index 6748e1886a1..78eaacc5a79 100644
--- a/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
+++ b/parser/sql/engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
@@ -127,6 +127,8 @@ public enum SQLVisitorRule {
DROP_FUNCTION("DropFunction", SQLStatementType.DDL),
+ RELOAD_FUNCTION("ReloadFunction", SQLStatementType.DDL),
+
DROP_GROUP("DropGroup", SQLStatementType.DDL),
CREATE_DATABASE("CreateDatabase", SQLStatementType.DDL),
diff --git a/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4 b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/ddl/function/ReloadFunctionStatement.java
similarity index 54%
copy from parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
copy to parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/ddl/function/ReloadFunctionStatement.java
index 0302be3c669..9779a1651f6 100644
--- a/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
+++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/ddl/function/ReloadFunctionStatement.java
@@ -15,39 +15,17 @@
* limitations under the License.
*/
-grammar HiveStatement;
+package org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.function;
-import Comments, DMLStatement, DDLStatement;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.DDLStatement;
-// TODO correct hive SQL parsing according to official documentation
-execute
- : (select
- | insert
- | update
- | delete
- | loadStatement
- | createDatabase
- | dropDatabase
- | alterDatabase
- | use
- | createTable
- | dropTable
- | truncateTable
- | msckStatement
- | alterTable
- | createView
- | dropView
- | alterView
- | createMaterializedView
- | dropMaterializedView
- | alterMaterializedView
- | createIndex
- | dropIndex
- | alterIndex
- | createMacro
- | dropMacro
- | createFunction
- | dropFunction
- ) (SEMI_ EOF? | EOF)
- | EOF
- ;
+/**
+ * Reload function statement.
+ */
+public final class ReloadFunctionStatement extends DDLStatement {
+
+ public ReloadFunctionStatement(final DatabaseType databaseType) {
+ super(databaseType);
+ }
+}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
index e2b1cc418ba..f439de63bc6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/RootSQLParserTestCases.java
@@ -256,6 +256,7 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.function.AlterFunctionStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.function.CreateFunctionStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.function.DropFunctionStatementTestCase;
+import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.function.ReloadFunctionStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.AlterIndexStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.CreateIndexStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.DropIndexStatementTestCase;
@@ -1760,6 +1761,9 @@ public final class RootSQLParserTestCases {
@XmlElement(name = "drop-macro")
private final List<DropMacroStatementTestCase> dropMacroTestCases = new LinkedList<>();
+ @XmlElement(name = "reload-function")
+ private final List<ReloadFunctionStatementTestCase> reloadFunctionStatementTestCases = new LinkedList<>();
+
/**
* Get all SQL parser test cases.
*
diff --git a/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4 b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/standard/function/ReloadFunctionStatementTestCase.java
similarity index 54%
copy from parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
copy to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/standard/function/ReloadFunctionStatementTestCase.java
index 0302be3c669..57616b6c38c 100644
--- a/parser/sql/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/standard/function/ReloadFunctionStatementTestCase.java
@@ -15,39 +15,12 @@
* limitations under the License.
*/
-grammar HiveStatement;
+package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.function;
-import Comments, DMLStatement, DDLStatement;
+import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
-// TODO correct hive SQL parsing according to official documentation
-execute
- : (select
- | insert
- | update
- | delete
- | loadStatement
- | createDatabase
- | dropDatabase
- | alterDatabase
- | use
- | createTable
- | dropTable
- | truncateTable
- | msckStatement
- | alterTable
- | createView
- | dropView
- | alterView
- | createMaterializedView
- | dropMaterializedView
- | alterMaterializedView
- | createIndex
- | dropIndex
- | alterIndex
- | createMacro
- | dropMacro
- | createFunction
- | dropFunction
- ) (SEMI_ EOF? | EOF)
- | EOF
- ;
+/**
+ * Reload function statement test case.
+ */
+public final class ReloadFunctionStatementTestCase extends SQLParserTestCase {
+}
diff --git a/test/it/parser/src/main/resources/case/ddl/reload-function.xml b/test/it/parser/src/main/resources/case/ddl/reload-function.xml
new file mode 100644
index 00000000000..990aa4aea9b
--- /dev/null
+++ b/test/it/parser/src/main/resources/case/ddl/reload-function.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<sql-parser-test-cases>
+ <reload-function sql-case-id="reload_functions" />
+ <reload-function sql-case-id="reload_function" />
+</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/reload-function.xml b/test/it/parser/src/main/resources/sql/supported/ddl/reload-function.xml
new file mode 100644
index 00000000000..85930297426
--- /dev/null
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/reload-function.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<sql-cases>
+ <sql-case id="reload_functions" value="RELOAD FUNCTIONS;" db-types="Hive" />
+ <sql-case id="reload_function" value="RELOAD FUNCTION;" db-types="Hive" />
+</sql-cases>