Skip to content

Commit

Permalink
[FLINK-21620][table] Use TIMESTAMP_LTZ as summary string for LocalZon…
Browse files Browse the repository at this point in the history
…edTimestampType

This closes #15124.
  • Loading branch information
twalthr committed Mar 11, 2021
1 parent bb15784 commit a10382e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public static List<TestItem> testData() {
"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)",
Expand All @@ -128,8 +128,8 @@ public static List<TestItem> testData() {
"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",
Expand All @@ -144,8 +144,8 @@ public static List<TestItem> testData() {
"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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
*
* <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
Expand All @@ -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(),
Expand Down Expand Up @@ -137,9 +140,9 @@ public String asSerializableString() {
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public void testLocalZonedTimestampType() {
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[] {},
Expand All @@ -344,7 +344,7 @@ public void testLocalZonedTimestampTypeWithTimeAttribute() {
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[] {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a10382e

Please sign in to comment.