leonardBang commented on a change in pull request #14620:
URL: https://github.com/apache/flink/pull/14620#discussion_r556379717



##########
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/expressions/NonDeterministicTests.scala
##########
@@ -65,11 +70,38 @@ class NonDeterministicTests extends ExpressionTestBase {
   }
 
   @Test
-  def testLocalTimestamp(): Unit = {
-    testAllApis(
-      localTimestamp().isGreater("1970-01-01 00:00:00".toTimestamp),
-      "localTimestamp() > '1970-01-01 00:00:00'.toTimestamp",
-      "LOCALTIMESTAMP > TIMESTAMP '1970-01-01 00:00:00'",
+  def testLocalTimestampInUTC(): Unit = {
+    config.setLocalTimeZone(ZoneId.of("UTC"))
+    val localDateTime = LocalDateTime.now(ZoneId.of("UTC"))
+
+    val formattedLocalTime = 
localDateTime.toLocalTime.format(DateTimeFormatter.ofPattern("HH:mm:ss"))
+    val formattedLocalDateTime = 
localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+
+    // the LOCALTIME/LOCALTIMESTAMP functions are not deterministic, thus we
+    // use following pattern to check it return SQL timestamp in session time 
zone UTC
+    testSqlApi(
+      s"TIMESUB(LOCALTIME, TIME '$formattedLocalTime') <= 60000",

Review comment:
       we'd better call it `SUB` rather than `DIFF`  because we assume the t1 
produced before t2, if not, we don't know the lag between two inputs in the 
cornor case that t1 = '23:59:59' and t2 = '00:00:01'




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to