Skip to content

Commit dbea275

Browse files
committed
[FLINK-22525][table-api] Fix gmt format in Flink from GMT-8:00 to GMT-08:00
1 parent f39af7e commit dbea275

File tree

15 files changed

+33
-20
lines changed

15 files changed

+33
-20
lines changed

docs/content.zh/docs/connectors/table/filesystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ file sink 支持文件合并,以允许应用程序可以使用较小的检查
224224
该参数只有在参数 `sink.partition-commit.trigger` 被设置为 'partition-time' 时才生效。
225225
如果该参数设置的不正确,比如在 TIMESTAMP_LTZ 列上定义了 source rowtime, 但没有设置该参数,则用户可能在若干个小时后才看到分区的提交。
226226
该参数的默认值是 'UTC', 代表水印是定义在 TIMESTAMP 列上或没有定义水印。 如果水印定义在 TIMESTAMP_LTZ 列上,则水印的时区是会话的时区。
227-
该参数的可选值要么是完整的时区名比如 'America/Los_Angeles',要么是自定义的时区 id 比如 'GMT-8:00'.</td>
227+
该参数的可选值要么是完整的时区名比如 'America/Los_Angeles',要么是自定义的时区 id 比如 'GMT-08:00'.</td>
228228
</tr>
229229
</tbody>
230230
</table>

docs/content/docs/connectors/table/filesystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ To define when to commit a partition, providing partition commit trigger:
229229
<td><h5>sink.partition-commit.watermark-time-zone</h5></td>
230230
<td style="word-wrap: break-word;">UTC</td>
231231
<td>String</td>
232-
<td>The time zone to parse the long watermark value to TIMESTAMP value, the parsed watermark timestamp is used to compare with partition time to decide the partition should commit or not. This option is only take effect when `sink.partition-commit.trigger` is set to 'partition-time'. If this option is not configured correctly, e.g. source rowtime is defined on TIMESTAMP_LTZ column, but this config is not configured, then users may see the partition committed after a few hours. The default value is 'UTC', which means the watermark is defined on TIMESTAMP column or not defined. If the watermark is defined on TIMESTAMP_LTZ column, the time zone of watermark is the session time zone. The option value is either a full name such as 'America/Los_Angeles', or a custom timezone id such as 'GMT-8:00'.</td>
232+
<td>The time zone to parse the long watermark value to TIMESTAMP value, the parsed watermark timestamp is used to compare with partition time to decide the partition should commit or not. This option is only take effect when `sink.partition-commit.trigger` is set to 'partition-time'. If this option is not configured correctly, e.g. source rowtime is defined on TIMESTAMP_LTZ column, but this config is not configured, then users may see the partition committed after a few hours. The default value is 'UTC', which means the watermark is defined on TIMESTAMP column or not defined. If the watermark is defined on TIMESTAMP_LTZ column, the time zone of watermark is the session time zone. The option value is either a full name such as 'America/Los_Angeles', or a custom timezone id such as 'GMT-08:00'.</td>
233233
</tr>
234234
</tbody>
235235
</table>

docs/data/sql_functions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ temporal:
471471
table: timestampDiff(TIMEPOINTUNIT, TIMEPOINT1, TIMEPOINT2)
472472
description: 'Returns the (signed) number of timepointunit between timepoint1 and timepoint2. The unit for the interval is given by the first argument, which should be one of the following values: SECOND, MINUTE, HOUR, DAY, MONTH, or YEAR.'
473473
- sql: CONVERT_TZ(string1, string2, string3)
474-
description: Converts a datetime string1 (with default ISO timestamp format 'yyyy-MM-dd HH:mm:ss') from time zone string2 to time zone string3. The format of time zone should be either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00". E.g., CONVERT_TZ('1970-01-01 00:00:00', 'UTC', 'America/Los_Angeles') returns '1969-12-31 16:00:00'.
474+
description: Converts a datetime string1 (with default ISO timestamp format 'yyyy-MM-dd HH:mm:ss') from time zone string2 to time zone string3. The format of time zone should be either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-08:00". E.g., CONVERT_TZ('1970-01-01 00:00:00', 'UTC', 'America/Los_Angeles') returns '1969-12-31 16:00:00'.
475475
- sql: FROM_UNIXTIME(numeric[, string])
476476
description: Returns a representation of the numeric argument as a value in string format (default is 'yyyy-MM-dd HH:mm:ss'). numeric is an internal timestamp value representing seconds since '1970-01-01 00:00:00' UTC, such as produced by the UNIX_TIMESTAMP() function. The return value is expressed in the session time zone (specified in TableConfig). E.g., FROM_UNIXTIME(44) returns '1970-01-01 00:00:44' if in UTC time zone, but returns '1970-01-01 09:00:44' if in 'Asia/Tokyo' time zone.
477477
- sql: UNIX_TIMESTAMP()

docs/layouts/shortcodes/generated/table_config_configuration.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<td><h5>table.local-time-zone</h5><br> <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span></td>
3131
<td style="word-wrap: break-word;">"default"</td>
3232
<td>String</td>
33-
<td>The local time zone defines current session time zone id. It is used when converting to/from &lt;code&gt;TIMESTAMP WITH LOCAL TIME ZONE&lt;/code&gt;. Internally, timestamps with local time zone are always represented in the UTC time zone. However, when converting to data types that don't include a time zone (e.g. TIMESTAMP, TIME, or simply STRING), the session time zone is used during conversion. The input of option is either a full name such as "America/Los_Angeles", or a custom timezone id such as "GMT-8:00".</td>
33+
<td>The local time zone defines current session time zone id. It is used when converting to/from &lt;code&gt;TIMESTAMP WITH LOCAL TIME ZONE&lt;/code&gt;. Internally, timestamps with local time zone are always represented in the UTC time zone. However, when converting to data types that don't include a time zone (e.g. TIMESTAMP, TIME, or simply STRING), the session time zone is used during conversion. The input of option is either a full name such as "America/Los_Angeles", or a custom timezone id such as "GMT-08:00".</td>
3434
</tr>
3535
<tr>
3636
<td><h5>table.planner</h5><br> <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span></td>

flink-python/pyflink/datastream/connectors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ def date_time_bucket_assigner(format_str: str = "yyyy-MM-dd--HH", timezone_id: s
573573
:param format_str: The format string used to determine the bucket id.
574574
:param timezone_id: The timezone id, either an abbreviation such as "PST", a full name
575575
such as "America/Los_Angeles", or a custom timezone_id such as
576-
"GMT-8:00". Th e default time zone will b used if it's None.
576+
"GMT-08:00". Th e default time zone will b used if it's None.
577577
"""
578578
if timezone_id is not None and isinstance(timezone_id, str):
579579
j_timezone = get_gateway().jvm.java.time.ZoneId.of(timezone_id)

flink-python/pyflink/table/table_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_local_timezone(self) -> str:
5656
"""
5757
Returns the local timezone id for timestamp with local time zone, either an abbreviation
5858
such as "PST", a full name such as "America/Los_Angeles", or a custom timezone_id such
59-
as "GMT-8:00".
59+
as "GMT-08:00".
6060
"""
6161
return self._j_table_config.getLocalTimeZone().getId()
6262

@@ -66,7 +66,7 @@ def set_local_timezone(self, timezone_id: str):
6666
6767
:param timezone_id: The timezone id, either an abbreviation such as "PST", a full name
6868
such as "America/Los_Angeles", or a custom timezone_id such as
69-
"GMT-8:00".
69+
"GMT-08:00".
7070
"""
7171
if timezone_id is not None and isinstance(timezone_id, str):
7272
j_timezone = get_gateway().jvm.java.time.ZoneId.of(timezone_id)

flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/windowing/TimeWindowTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testGetWindowStartWithOffset() {
5353
Assert.assertEquals(TimeWindow.getWindowStartWithOffset(7, offset, 7), 5);
5454
Assert.assertEquals(TimeWindow.getWindowStartWithOffset(12, offset, 7), 12);
5555

56-
// for GMT+8:00
56+
// for GMT+08:00
5757
offset = -TimeUnit.HOURS.toMillis(8);
5858
long size = TimeUnit.DAYS.toMillis(1);
5959
Assert.assertEquals(

flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/TableConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private void validateTimeZone(String zone) {
182182
throw new IllegalArgumentException(
183183
String.format(
184184
"The supported Zone ID is either a full name such as 'America/Los_Angeles',"
185-
+ " or a custom timezone id such as 'GMT-8:00', but configured Zone ID is '%s'.",
185+
+ " or a custom timezone id such as 'GMT-08:00', but configured Zone ID is '%s'.",
186186
zone));
187187
}
188188
}

flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/config/TableConfigOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private TableConfigOptions() {}
9090
+ "<code>TIMESTAMP WITH LOCAL TIME ZONE</code>. Internally, timestamps with local time zone are always represented in the UTC time zone. "
9191
+ "However, when converting to data types that don't include a time zone (e.g. TIMESTAMP, TIME, or simply STRING), "
9292
+ "the session time zone is used during conversion. The input of option is either a full name "
93-
+ "such as \"America/Los_Angeles\", or a custom timezone id such as \"GMT-8:00\".");
93+
+ "such as \"America/Los_Angeles\", or a custom timezone id such as \"GMT-08:00\".");
9494

9595
@Documentation.TableOption(execMode = Documentation.ExecMode.BATCH_STREAMING)
9696
public static final ConfigOption<Integer> MAX_LENGTH_GENERATED_CODE =

flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/api/TableConfigTest.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,36 @@ public void testSetAndGetLocalTimeZone() {
6666

6767
assertEquals(ZoneId.of("Asia/Shanghai"), configByMethod.getLocalTimeZone());
6868
assertEquals(ZoneId.of("Asia/Shanghai"), configByConfiguration.getLocalTimeZone());
69+
70+
configuration.setString("table.local-time-zone", "GMT-08:00");
71+
configByConfiguration.addConfiguration(configuration);
72+
configByMethod.setLocalTimeZone(ZoneId.of("GMT-08:00"));
73+
74+
assertEquals(ZoneId.of("GMT-08:00"), configByMethod.getLocalTimeZone());
75+
assertEquals(ZoneId.of("GMT-08:00"), configByConfiguration.getLocalTimeZone());
6976
}
7077

7178
@Test
7279
public void testSetInvalidLocalTimeZone() {
7380
expectedException.expectMessage(
7481
"The supported Zone ID is either a full name such as 'America/Los_Angeles',"
75-
+ " or a custom timezone id such as 'GMT-8:00', but configured Zone ID is 'UTC-10:00'.");
82+
+ " or a custom timezone id such as 'GMT-08:00', but configured Zone ID is 'UTC-10:00'.");
7683
configByMethod.setLocalTimeZone(ZoneId.of("UTC-10:00"));
7784
}
7885

86+
@Test
87+
public void testInvalidGmtLocalTimeZone() {
88+
expectedException.expectMessage("Invalid ID for offset-based ZoneId: GMT-8:00");
89+
configByMethod.setLocalTimeZone(ZoneId.of("GMT-8:00"));
90+
}
91+
7992
@Test
8093
public void testGetInvalidLocalTimeZone() {
8194
configuration.setString("table.local-time-zone", "UTC+8");
8295
configByConfiguration.addConfiguration(configuration);
8396
expectedException.expectMessage(
8497
"The supported Zone ID is either a full name such as 'America/Los_Angeles',"
85-
+ " or a custom timezone id such as 'GMT-8:00', but configured Zone ID is 'UTC+8'.");
98+
+ " or a custom timezone id such as 'GMT-08:00', but configured Zone ID is 'UTC+8'.");
8699
configByConfiguration.getLocalTimeZone();
87100
}
88101

@@ -92,7 +105,7 @@ public void testGetInvalidAbbreviationLocalTimeZone() {
92105
configByConfiguration.addConfiguration(configuration);
93106
expectedException.expectMessage(
94107
"The supported Zone ID is either a full name such as 'America/Los_Angeles',"
95-
+ " or a custom timezone id such as 'GMT-8:00', but configured Zone ID is 'PST'.");
108+
+ " or a custom timezone id such as 'GMT-08:00', but configured Zone ID is 'PST'.");
96109
configByConfiguration.getLocalTimeZone();
97110
}
98111

0 commit comments

Comments
 (0)