You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tw...@apache.org on 2021/10/07 14:16:37 UTC
[flink] branch master updated: [FLINK-24421][table-runtime] Fix
conversion of strings to TIME
This is an automated email from the ASF dual-hosted git repository.
twalthr 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 18ffed7 [FLINK-24421][table-runtime] Fix conversion of strings to TIME
18ffed7 is described below
commit 18ffed7757551c0219b40c793bca6782636d9a40
Author: Marios Trivyzas <ma...@gmail.com>
AuthorDate: Mon Oct 4 18:57:56 2021 +0300
[FLINK-24421][table-runtime] Fix conversion of strings to TIME
Following calcite-avatica behaviour, fix the behaviour of parsing
string into unix time when the string is incomplete, missing 1 or
both `:` time units separator. Previously, minutes and seconds where
set to default value `1` instead of `0` when missing from the parsed
string. Issue was fixed in avatica with:
https://github.com/apache/calcite-avatica/commit/cac2ffaaf97572d21cba195d7590d9ab0d32382e
This closes #17418.
---
.../apache/flink/table/planner/functions/CastFunctionITCase.java | 6 +++---
.../org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java
index e13fb66..bbeec8a 100644
--- a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java
+++ b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java
@@ -577,7 +577,6 @@ public class CastFunctionITCase extends BuiltInFunctionTestBase {
CastTestSpecBuilder.testCastTo(DATE())
.fromCase(CHAR(3), "foo", null)
.fromCase(VARCHAR(5), "Flink", null)
- // https://issues.apache.org/jira/browse/FLINK-24421 Bug
.fromCase(STRING(), "123", LocalDate.of(123, 1, 1))
.fromCase(STRING(), "2021-09-27", LocalDate.of(2021, 9, 27))
.fromCase(
@@ -633,9 +632,10 @@ public class CastFunctionITCase extends BuiltInFunctionTestBase {
CastTestSpecBuilder.testCastTo(TIME())
.fromCase(CHAR(3), "foo", null)
.fromCase(VARCHAR(5), "Flink", null)
- // https://issues.apache.org/jira/browse/FLINK-24421 Bug
- .fromCase(STRING(), "123", LocalTime.of(23, 1, 1))
+ .fromCase(STRING(), "123", LocalTime.of(23, 0, 0))
+ .fromCase(STRING(), "123:45", LocalTime.of(23, 45, 0))
.fromCase(STRING(), "2021-09-27", null)
+ .fromCase(STRING(), "2021-09-27 12:34:56", null)
// https://issues.apache.org/jira/browse/FLINK-17224 Fractional seconds are
// lost
.fromCase(STRING(), "12:34:56.123456789", LocalTime.of(12, 34, 56, 0))
diff --git a/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java b/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
index 0a98afc..8d033d0 100644
--- a/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
+++ b/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java
@@ -1465,8 +1465,8 @@ public class SqlDateTimeUtils {
return null;
}
hour = Integer.parseInt(v.substring(start, end).trim());
- minute = 1;
- second = 1;
+ minute = 0;
+ second = 0;
milli = 0;
} else {
if (!isInteger(v.substring(start, colon1).trim())) {
@@ -1479,7 +1479,7 @@ public class SqlDateTimeUtils {
return null;
}
minute = Integer.parseInt(v.substring(colon1 + 1, end).trim());
- second = 1;
+ second = 0;
milli = 0;
} else {
if (!isInteger(v.substring(colon1 + 1, colon2).trim())) {