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



##########
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/expressions/NonDeterministicTests.scala
##########
@@ -96,4 +128,25 @@ class NonDeterministicTests extends ExpressionTestBase {
   override def testData: Row = new Row(0)
 
   override def typeInfo: RowTypeInfo = new RowTypeInfo()
+
+  override def functions: Map[String, ScalarFunction] = Map(
+    "TIME_SUB" -> TimeSubFun
+  )
+}
+
+object TimeSubFun extends ScalarFunction {
+
+  val millsInDay = 24*60*60*1000L

Review comment:
       Add space around multiplier operator.

##########
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:
       TIMESUB?




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to