This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 b1f540374e1 support new function (#38312)
b1f540374e1 is described below

commit b1f540374e1820f0add3b46d308f8b552b9ed526
Author: Claire <[email protected]>
AuthorDate: Fri Mar 6 23:45:10 2026 +0800

    support new function (#38312)
---
 .../hive/src/main/antlr4/imports/hive/DMLStatement.g4  | 10 +++++++++-
 test/it/parser/src/main/resources/case/dml/select.xml  | 18 ++++++++++++++++++
 .../src/main/resources/sql/supported/dml/select.xml    |  2 ++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git 
a/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DMLStatement.g4 
b/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DMLStatement.g4
index c83688ff639..89479cd98d0 100644
--- 
a/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DMLStatement.g4
+++ 
b/parser/sql/engine/dialect/hive/src/main/antlr4/imports/hive/DMLStatement.g4
@@ -209,7 +209,15 @@ tableReference
     ;
 
 tableFactor
-    : tableName partitionNames? (AS? alias)? indexHintList? | subquery AS? 
alias (LP_ columnNames RP_)? | LP_ tableReferences RP_
+    : tableName partitionNames? (forSystemTimeClause | 
forSystemVersionClause)? (AS? alias)? indexHintList? | subquery AS? alias (LP_ 
columnNames RP_)? | LP_ tableReferences RP_
+    ;
+
+forSystemTimeClause
+    : FOR SYSTEM_TIME AS OF string_
+    ;
+
+forSystemVersionClause
+    : FOR SYSTEM_VERSION AS OF (NUMBER_ | identifier)
     ;
 
 partitionNames
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml 
b/test/it/parser/src/main/resources/case/dml/select.xml
index 5638a16a7c5..5bb9667ea1d 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -14420,4 +14420,22 @@
             </expression-projection>
         </projections>
     </select>
+
+    <select sql-case-id="select_for_system_time_as_of_hive">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="table_a" start-index="14" stop-index="20" />
+        </from>
+    </select>
+
+    <select sql-case-id="select_for_system_version_as_of_hive">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="table_a" start-index="14" stop-index="20" />
+        </from>
+    </select>
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index 3867546b0de..6bbad212261 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -537,4 +537,6 @@
     <sql-case id="select_use_index_twice" value="SELECT * FROM t1 USE INDEX 
(i1) USE INDEX (i1,i1);" db-types="MySQL" />
     <sql-case id="select_use_index_force_index_for_join" value="SELECT * FROM 
t1 USE INDEX FOR JOIN (i1) FORCE INDEX FOR JOIN (i2);" db-types="MySQL" />
     <sql-case id="select_group_by_match_against_with_rollup" value="SELECT 1 
FROM t GROUP BY a, MATCH (a) AGAINST ('abc') WITH ROLLUP;" db-types="MySQL" />
+    <sql-case id="select_for_system_time_as_of_hive" value="SELECT * FROM 
table_a FOR SYSTEM_TIME AS OF '2021-08-09 10:35:57';" db-types="Hive" />
+    <sql-case id="select_for_system_version_as_of_hive" value="SELECT * FROM 
table_a FOR SYSTEM_VERSION AS OF 1234567;" db-types="Hive" />
 </sql-cases>

Reply via email to