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 70c4df4  fix utc timestamp function (#13867)
70c4df4 is described below

commit 70c4df4c10a22119fb400db7061f916d14385f45
Author: tuichenchuxin <[email protected]>
AuthorDate: Tue Nov 30 17:28:56 2021 +0800

    fix utc timestamp function (#13867)
---
 .../src/main/antlr4/imports/mysql/BaseRule.g4           |  2 +-
 .../src/main/resources/case/dml/select-expression.xml   | 17 +++++++++++++++++
 .../resources/sql/supported/dml/select-expression.xml   |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index 619285d..085ef2d 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -1045,7 +1045,7 @@ regularFunctionName
     | DATABASE | SCHEMA | LEFT | RIGHT | DATE | DAY | GEOMETRYCOLLECTION
     | LINESTRING | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | POINT | 
POLYGON
     | TIME | TIMESTAMP | TIMESTAMP_ADD | TIMESTAMP_DIFF | DATE | 
CURRENT_TIMESTAMP 
-    | CURRENT_DATE | CURRENT_TIME | identifier
+    | CURRENT_DATE | CURRENT_TIME | UTC_TIMESTAMP | identifier
     ;
     
 matchExpression
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-expression.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-expression.xml
index 6882982..893a7d4 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-expression.xml
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/select-expression.xml
@@ -1974,4 +1974,21 @@
             </expr>
         </where>
     </select>
+
+    <select sql-case-id="select_with_regular_function_utc_timestamp">
+        <projections start-index="7" stop-index="38">
+            <expression-projection text="TIMEDIFF(NOW(), UTC_TIMESTAMP())" 
start-index="7" stop-index="38">
+                <expr>
+                    <function function-name="TIMEDIFF" text="TIMEDIFF(NOW(), 
UTC_TIMESTAMP())" start-index="7" stop-index="38">
+                        <parameter>
+                            <function function-name="NOW" text="NOW()" 
start-index="16" stop-index="20" />
+                        </parameter>
+                        <parameter>
+                            <function function-name="UTC_TIMESTAMP" 
text="UTC_TIMESTAMP()" start-index="23" stop-index="37" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
 </sql-parser-test-cases>
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/select-expression.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/select-expression.xml
index 45b94d1..c88d76d 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/select-expression.xml
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/select-expression.xml
@@ -85,4 +85,5 @@
     <sql-case id="select_with_abs_function" value="SELECT ABS(1) FROM t_order 
WHERE ABS(1) &gt; 1 GROUP BY ABS(1) ORDER BY ABS(1)" db-types="MySQL,Oracle" />
     <sql-case id="select_with_regular_function" value="SELECT A(1) FROM 
t_order WHERE A(1) = 1 GROUP BY A(order_id) ORDER BY A(order_id)" 
db-types="MySQL,Oracle,SQLServer" />
     <sql-case id="select_with_regular_function_for_sql92" value="SELECT A(1) 
FROM t_order WHERE A(1) = 1" db-types="MySQL,Oracle,SQLServer,H2,SQL92" />
+    <sql-case id="select_with_regular_function_utc_timestamp" value="SELECT 
TIMEDIFF(NOW(), UTC_TIMESTAMP())" db-types="MySQL" />
 </sql-cases>

Reply via email to