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/03/11 20:58:06 UTC
[flink] 02/02: [FLINK-21620][table] Use TIMESTAMP_LTZ as summary
string for LocalZonedTimestampType
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
commit a10382e3989357f375a68e6ec89829a1a7c89721
Author: Timo Walther <tw...@apache.org>
AuthorDate: Thu Mar 11 15:46:12 2021 +0100
[FLINK-21620][table] Use TIMESTAMP_LTZ as summary string for LocalZonedTimestampType
This closes #15124.
---
.../org/apache/flink/connector/jdbc/JdbcDataTypeTest.java | 12 ++++++------
.../flink/table/types/logical/LocalZonedTimestampType.java | 9 ++++++---
.../java/org/apache/flink/table/types/LogicalTypesTest.java | 4 ++--
.../org/apache/flink/table/api/TableEnvironmentTest.scala | 4 ++--
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcDataTypeTest.java b/flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcDataTypeTest.java
index 9017376..87233d4 100644
--- a/flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcDataTypeTest.java
+++ b/flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcDataTypeTest.java
@@ -110,8 +110,8 @@ public class JdbcDataTypeTest {
"The Derby dialect doesn't support type: VARBINARY(10)."),
createTestItem(
"derby",
- "TIMESTAMP(3) WITH LOCAL TIME ZONE",
- "The Derby dialect doesn't support type: TIMESTAMP(3) WITH LOCAL TIME ZONE."),
+ "TIMESTAMP_LTZ(3)",
+ "The Derby dialect doesn't support type: TIMESTAMP_LTZ(3)."),
createTestItem(
"derby",
"DECIMAL(38, 18)",
@@ -128,8 +128,8 @@ public class JdbcDataTypeTest {
"The precision of field 'f0' is out of the TIMESTAMP precision range [1, 6] supported by MySQL dialect."),
createTestItem(
"mysql",
- "TIMESTAMP(3) WITH LOCAL TIME ZONE",
- "The MySQL dialect doesn't support type: TIMESTAMP(3) WITH LOCAL TIME ZONE."),
+ "TIMESTAMP_LTZ(3)",
+ "The MySQL dialect doesn't support type: TIMESTAMP_LTZ(3)."),
createTestItem(
"postgresql",
"BINARY",
@@ -144,8 +144,8 @@ public class JdbcDataTypeTest {
"The precision of field 'f0' is out of the TIMESTAMP precision range [1, 6] supported by PostgreSQL dialect."),
createTestItem(
"postgresql",
- "TIMESTAMP(3) WITH LOCAL TIME ZONE",
- "The PostgreSQL dialect doesn't support type: TIMESTAMP(3) WITH LOCAL TIME ZONE."));
+ "TIMESTAMP_LTZ(3)",
+ "The PostgreSQL dialect doesn't support type: TIMESTAMP_LTZ(3)."));
}
private static TestItem createTestItem(Object... args) {
diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LocalZonedTimestampType.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LocalZonedTimestampType.java
index 284a33b..efd2110 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LocalZonedTimestampType.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/LocalZonedTimestampType.java
@@ -37,7 +37,8 @@ import java.util.Set;
*
* <p>The serialized string representation is {@code TIMESTAMP(p) WITH LOCAL TIME ZONE} where {@code
* p} is the number of digits of fractional seconds (=precision). {@code p} must have a value
- * between 0 and 9 (both inclusive). If no precision is specified, {@code p} is equal to 6.
+ * between 0 and 9 (both inclusive). If no precision is specified, {@code p} is equal to 6. {@code
+ * TIMESTAMP_LTZ(p)} is a synonym.
*
* <p>Compared to {@link ZonedTimestampType}, the time zone offset information is not stored
* physically in every datum. Instead, the type assumes {@link java.time.Instant} semantics in UTC
@@ -63,6 +64,8 @@ public final class LocalZonedTimestampType extends LogicalType {
private static final String FORMAT = "TIMESTAMP(%d) WITH LOCAL TIME ZONE";
+ private static final String SUMMARY_FORMAT = "TIMESTAMP_LTZ(%d)";
+
private static final Set<String> NULL_OUTPUT_CONVERSION =
conversionSet(
java.time.Instant.class.getName(),
@@ -137,9 +140,9 @@ public final class LocalZonedTimestampType extends LogicalType {
@Override
public String asSummaryString() {
if (kind != TimestampKind.REGULAR) {
- return String.format("%s *%s*", asSerializableString(), kind);
+ return String.format("%s *%s*", withNullability(SUMMARY_FORMAT, precision), kind);
}
- return asSerializableString();
+ return withNullability(SUMMARY_FORMAT, precision);
}
@Override
diff --git a/flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypesTest.java b/flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypesTest.java
index 239fa3d..9710663 100644
--- a/flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypesTest.java
+++ b/flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/LogicalTypesTest.java
@@ -332,7 +332,7 @@ public class LogicalTypesTest {
testAll(
new LocalZonedTimestampType(9),
"TIMESTAMP(9) WITH LOCAL TIME ZONE",
- "TIMESTAMP(9) WITH LOCAL TIME ZONE",
+ "TIMESTAMP_LTZ(9)",
new Class[] {java.time.Instant.class, long.class, int.class},
new Class[] {java.time.Instant.class},
new LogicalType[] {},
@@ -344,7 +344,7 @@ public class LogicalTypesTest {
testAll(
new LocalZonedTimestampType(true, TimestampKind.ROWTIME, 9),
"TIMESTAMP(9) WITH LOCAL TIME ZONE",
- "TIMESTAMP(9) WITH LOCAL TIME ZONE *ROWTIME*",
+ "TIMESTAMP_LTZ(9) *ROWTIME*",
new Class[] {java.time.Instant.class, long.class, int.class},
new Class[] {java.time.Instant.class},
new LogicalType[] {},
diff --git a/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala b/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala
index d1c7f31..b7c69c7 100644
--- a/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala
+++ b/flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala
@@ -1332,8 +1332,8 @@ class TableEnvironmentTest {
Row.of("f16", "TIMESTAMP(6)", Boolean.box(true), null, null, null),
Row.of("f17", "TIMESTAMP(3)", Boolean.box(true), null, null, null),
Row.of("f18", "TIMESTAMP(6)", Boolean.box(true), null, null, null),
- Row.of("f19", "TIMESTAMP(3) WITH LOCAL TIME ZONE", Boolean.box(true), null, null, null),
- Row.of("f20", "TIMESTAMP(6) WITH LOCAL TIME ZONE", Boolean.box(true), null, null, null),
+ Row.of("f19", "TIMESTAMP_LTZ(3)", Boolean.box(true), null, null, null),
+ Row.of("f20", "TIMESTAMP_LTZ(6)", Boolean.box(true), null, null, null),
Row.of("f21", "ARRAY<INT>", Boolean.box(true), null, null, null),
Row.of("f22", "MAP<INT, STRING>", Boolean.box(true), null, null, null),
Row.of("f23", "ROW<`f0` INT, `f1` STRING>", Boolean.box(true), null, null, null),