This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 9c6fdd7cb5c Support Hive OPTIMIZE Statement about iceberg statement
parse (#38877)
9c6fdd7cb5c is described below
commit 9c6fdd7cb5cf47bdc3226211ace43b63ebd2a23f
Author: Claire <[email protected]>
AuthorDate: Sun Jun 21 15:05:41 2026 +0800
Support Hive OPTIMIZE Statement about iceberg statement parse (#38877)
* support optimize
* release
---
RELEASE-NOTES.md | 1 +
.../engine/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4 | 1 +
.../dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4 | 4 ++++
.../apache/shardingsphere/sql/parser/autogen/HiveStatement.g4 | 1 +
.../hive/visitor/statement/type/HiveDALStatementVisitor.java | 9 +++++++++
test/it/parser/src/main/resources/case/dal/optimize.xml | 4 ++++
test/it/parser/src/main/resources/sql/supported/dal/optimize.xml | 1 +
7 files changed, 21 insertions(+)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 5f9ae6ce673..c4c581ec0df 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -34,6 +34,7 @@
1. Build: Support compiling and using ShardingSphere under OpenJDK 26 -
[#38625](https://github.com/apache/shardingsphere/issues/38625)
1. Metadata: Support Oracle dictionary views by adding SYS default system
schema and YAML definitions -
[#38388](https://github.com/apache/shardingsphere/pull/38388)
+1. SQL Parser: Support Hive OPTIMIZE Statement about iceberg statement parse -
[#38877](https://github.com/apache/shardingsphere/pull/38877)
1. SQL Parser: Support Hive DELETE ORPHAN-FILES Statement about iceberg
statement parse - [#38669](https://github.com/apache/shardingsphere/pull/38669)
1. SQL Parser: Support Hive ALTER TABLE... EXECUTE CHERRY-PICK about iceberg
statement parse- [#38823](https://github.com/apache/shardingsphere/pull/38823)
1. SQL Parser: Support MySQL Function statement parse -
[#38182](https://github.com/apache/shardingsphere/pull/38182)
[#38219](https://github.com/apache/shardingsphere/pull/38219)
diff --git
a/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4
b/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4
index a74fa98036c..26a8b65133a 100644
--- a/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4
+++ b/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/BaseRule.g4
@@ -412,6 +412,7 @@ identifierKeywordsUnambiguous
| ROUTINE
| ROW_COUNT
| ROW_FORMAT
+ | REWRITE
| RTREE
| SCHEDULE
| SCHEMA_NAME
diff --git
a/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4
b/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4
index 4b3f189e2b0..16019bbdf8e 100644
---
a/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4
+++
b/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DALStatement.g4
@@ -39,6 +39,10 @@ show
| showCompactions
;
+optimizeTable
+ : OPTIMIZE TABLE tableName REWRITE DATA
+ ;
+
describe
: describeDatabase
| describeConnector
diff --git
a/parser/sql/engine/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
b/parser/sql/engine/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
index 8609112493a..962d2e4d6db 100644
---
a/parser/sql/engine/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
+++
b/parser/sql/engine/dialect/hive/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/HiveStatement.g4
@@ -51,6 +51,7 @@ execute
| dropFunction
| reloadFunction
| show
+ | optimizeTable
| describe
| abort
) (SEMI_ EOF? | EOF)
diff --git
a/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDALStatementVisitor.java
b/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDALStatementVisitor.java
index 9aa84f6b615..cef8211bdfe 100644
---
a/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDALStatementVisitor.java
+++
b/parser/sql/engine/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/engine/hive/visitor/statement/type/HiveDALStatementVisitor.java
@@ -23,6 +23,7 @@ import
org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DALStatem
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DescribeConnectorContext;
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DescribeDatabaseContext;
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.DescribeTableContext;
+import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.OptimizeTableContext;
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowColumnsContext;
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowCompactionsContext;
import
org.apache.shardingsphere.sql.parser.autogen.HiveStatementParser.ShowConfContext;
@@ -72,6 +73,9 @@ import
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.index.MySQL
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.table.MySQLOptimizeTableStatement;
+
+import java.util.Collections;
/**
* DAL statement visitor for Hive.
@@ -88,6 +92,11 @@ public final class HiveDALStatementVisitor extends
HiveStatementVisitor implemen
return new MySQLUseStatement(getDatabaseType(), database);
}
+ @Override
+ public ASTNode visitOptimizeTable(final OptimizeTableContext ctx) {
+ return new MySQLOptimizeTableStatement(getDatabaseType(),
Collections.singleton((SimpleTableSegment) visit(ctx.tableName())));
+ }
+
@Override
public ASTNode visitShowDatabases(final ShowDatabasesContext ctx) {
ShowFilterSegment filter = null;
diff --git a/test/it/parser/src/main/resources/case/dal/optimize.xml
b/test/it/parser/src/main/resources/case/dal/optimize.xml
index 3e7268f51cc..e9844e6d9f4 100644
--- a/test/it/parser/src/main/resources/case/dal/optimize.xml
+++ b/test/it/parser/src/main/resources/case/dal/optimize.xml
@@ -21,4 +21,8 @@
<table name="table1" start-index="15" stop-index="20" />
<table name="table2" start-index="22" stop-index="27" />
</optimize-table>
+
+ <optimize-table sql-case-id="optimize_table_rewrite_data">
+ <table name="t" start-index="15" stop-index="15" />
+ </optimize-table>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dal/optimize.xml
b/test/it/parser/src/main/resources/sql/supported/dal/optimize.xml
index 94a203d03a0..502c0bd9b96 100644
--- a/test/it/parser/src/main/resources/sql/supported/dal/optimize.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dal/optimize.xml
@@ -18,4 +18,5 @@
<sql-cases>
<sql-case id="optimize_table" value="OPTIMIZE TABLE table1,table2"
db-types="MySQL,Doris" />
+ <sql-case id="optimize_table_rewrite_data" value="OPTIMIZE TABLE t REWRITE
DATA" db-types="Hive" />
</sql-cases>