You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/01/13 04:15:48 UTC

[GitHub] [flink] leonardBang commented on a change in pull request #14620: [FLINK-20940][table-planner] Use session time zone in LOCALTIME/LOCALTIMSTAMP functions

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



##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/expressions/TemporalTypesTest.scala
##########
@@ -674,6 +675,35 @@ class TemporalTypesTest extends ExpressionTestBase {
     //testSqlApi("CEIL(TIMESTAMP '2018-03-20 06:10:31' TO HOUR)", "2018-03-20 07:00:00.000")
   }
 
+  @Test
+  def testLocalDateTimeInUTC(): Unit = {
+    config.setLocalTimeZone(ZoneId.of("UTC"))
+
+    val formattedLocalDateTime = LocalDateTime
+      .now(ZoneId.of("UTC"))
+      .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+
+    // the LOCALTIMESTAMP function is not deterministic, thus we
+    // use following pattern to check it return SQL timestamp in session time zone UTC
+    testSqlApi(
+      s"TIMESTAMPDIFF(MINUTE, TIMESTAMP '$formattedLocalDateTime', LOCALTIMESTAMP) <= 1",
+      "true")
+  }
+
+  @Test
+  def testLocalDateTimeInShanghai(): Unit = {

Review comment:
       okay,`LOCALTIME` may cross different date eg 23:59:59:000, 00:00:00.001 and I didn't find a time function to compare them, but `LOCALTIME` comes from `LOCALTIMESTAMP` which has cover the time zone code path.




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