You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ja...@apache.org on 2019/05/21 02:15:16 UTC
[flink] branch master updated: [FLINK-12553][table-runtime-blink]
Fix bug that SqlDateTimeUtils#parseToTimeMillis doesn't parse millisecond
correctly
This is an automated email from the ASF dual-hosted git repository.
jark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new a86bce5 [FLINK-12553][table-runtime-blink] Fix bug that SqlDateTimeUtils#parseToTimeMillis doesn't parse millisecond correctly
a86bce5 is described below
commit a86bce5a176144e06d0120b804f3af986c325ebf
Author: liyafan82 <fa...@foxmail.com>
AuthorDate: Mon May 20 15:18:03 2019 +0800
[FLINK-12553][table-runtime-blink] Fix bug that SqlDateTimeUtils#parseToTimeMillis doesn't parse millisecond correctly
This closes #8483
---
.../scala/org/apache/flink/table/expressions/TemporalTypesTest.scala | 1 +
.../java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/expressions/TemporalTypesTest.scala b/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/expressions/TemporalTypesTest.scala
index 8141148..7460c48 100644
--- a/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/expressions/TemporalTypesTest.scala
+++ b/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/expressions/TemporalTypesTest.scala
@@ -493,6 +493,7 @@ class TemporalTypesTest extends ExpressionTestBase {
testSqlApi("DATEDIFF(TO_TIMESTAMP(1520827201000), '2018-03-11 12:00:01')", "1")
testSqlApi("DATEDIFF(TO_TIMESTAMP(1520827201000), TO_TIMESTAMP(1520740801000))", "1")
testSqlApi("DATEDIFF('2018-03-12 12:00:01', '2018-03-11 12:00:01')", "1")
+ testSqlApi("DATEDIFF('2018-03-13 00:00:00', '2018-03-12 23:59:59.123')", "1")
testSqlApi("DATEDIFF('2018-03-12 12:00:01', TO_TIMESTAMP(1520740801000))", "1")
testSqlApi("DATEDIFF(TO_TIMESTAMP(1520740801000), '2018-03-12 12:00:01')", "-1")
diff --git a/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java b/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
index 26e20d6..36959d7 100644
--- a/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
+++ b/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
@@ -486,7 +486,7 @@ public class SqlDateTimeUtils {
return Integer.parseInt(dateStr.substring(20)) * 10;
} else if (length >= 23 && length <= 26) {
// "1999-12-31 12:34:56.123" ~ "1999-12-31 12:34:56.123456"
- return Integer.parseInt(dateStr.substring(20, 23)) * 10;
+ return Integer.parseInt(dateStr.substring(20, 23));
} else {
return 0;
}