You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ComingWen (via GitHub)" <gi...@apache.org> on 2025/08/25 06:52:35 UTC
[PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
ComingWen opened a new pull request, #20402:
URL: https://github.com/apache/kafka/pull/20402
Delete this text and replace it with a detailed description of your change. The
PR title and body will become the squashed commit message.
If you would like to tag individuals, add some commentary, upload images, or
include other supplemental information that should not be part of the eventual
commit message, please use a separate comment.
If applicable, please include a summary of the testing strategy (including
rationale) for the proposed change. Unit and/or integration tests are expected
for any behavior change and system tests should be considered for larger
changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #20402: Add support to set the target timezone when we use the TimestampConverter.
URL: https://github.com/apache/kafka/pull/20402
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "LiamClarkeNZ (via GitHub)" <gi...@apache.org>.
LiamClarkeNZ commented on code in PR #20402:
URL: https://github.com/apache/kafka/pull/20402#discussion_r2403728622
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -83,7 +86,8 @@ public abstract class TimestampConverter<R extends ConnectRecord<R>> implements
private static final String UNIX_PRECISION_NANOS = "nanoseconds";
private static final String UNIX_PRECISION_SECONDS = "seconds";
- private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
+ private static TimeZone UTC = TimeZone.getTimeZone("UTC");
+ //private static final TimeZone UTC = TimeZone.getTimeZone("Asia/Shanghai");
Review Comment:
Dead code. Also, please re-add the `final` keyword to UTC.
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -68,6 +68,9 @@ public abstract class TimestampConverter<R extends ConnectRecord<R>> implements
public static final String UNIX_PRECISION_CONFIG = "unix.precision";
private static final String UNIX_PRECISION_DEFAULT = "milliseconds";
+ public static final String TIMEZONE_CONFIG = "time_zone";
Review Comment:
```suggestion
public static final String TIMEZONE_CONFIG = "time.zone";
```
Consistent naming please :)
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -271,16 +277,18 @@ public Date toType(Config config, Date orig) {
// This is a bit unusual, but allows the transformation config to be passed to static anonymous classes to customize
// their behavior
private static class Config {
- Config(String field, String type, SimpleDateFormat format, String unixPrecision) {
+ Config(String field, String type, SimpleDateFormat format, String unixPrecision, String time_zone) {
this.field = field;
this.type = type;
this.format = format;
this.unixPrecision = unixPrecision;
+ this.time_zone= time_zone;
Review Comment:
```suggestion
this.timeZone = timeZone;
```
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -271,16 +277,18 @@ public Date toType(Config config, Date orig) {
// This is a bit unusual, but allows the transformation config to be passed to static anonymous classes to customize
// their behavior
private static class Config {
- Config(String field, String type, SimpleDateFormat format, String unixPrecision) {
+ Config(String field, String type, SimpleDateFormat format, String unixPrecision, String time_zone) {
Review Comment:
```suggestion
Config(String field, String type, SimpleDateFormat format, String unixPrecision, String timeZone) {
```
Please keep casing consistent :)
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -293,12 +301,18 @@ public void configure(Map<String, ?> configs) {
final String type = simpleConfig.getString(TARGET_TYPE_CONFIG);
String formatPattern = simpleConfig.getString(FORMAT_CONFIG);
final String unixPrecision = simpleConfig.getString(UNIX_PRECISION_CONFIG);
+ final String time_zone = simpleConfig.getString(TIMEZONE_CONFIG);
schemaUpdateCache = new SynchronizedCache<>(new LRUCache<>(16));
replaceNullWithDefault = simpleConfig.getBoolean(REPLACE_NULL_WITH_DEFAULT_CONFIG);
if (type.equals(TYPE_STRING) && Utils.isBlank(formatPattern)) {
throw new ConfigException("TimestampConverter requires format option to be specified when using string timestamps");
}
+
+ if (!Utils.isBlank(time_zone)) {
+ UTC = TimeZone.getTimeZone(time_zone);
Review Comment:
Please don't reassign a timezone that likely isn't UTC to a constant called `UTC` :) I'd suggest using a new field.
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -92,6 +96,8 @@ public abstract class TimestampConverter<R extends ConnectRecord<R>> implements
public static final ConfigDef CONFIG_DEF = new ConfigDef()
.define(FIELD_CONFIG, ConfigDef.Type.STRING, FIELD_DEFAULT, ConfigDef.Importance.HIGH,
"The field containing the timestamp, or empty if the entire value is a timestamp")
+ .define(TIMEZONE_CONFIG, ConfigDef.Type.STRING, TIMEZONE_DEFAULT, ConfigDef.Importance.HIGH,
+ "The field containing the time_zone.")
Review Comment:
```suggestion
"The field containing the time zone.")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20402:
URL: https://github.com/apache/kafka/pull/20402#issuecomment-3243660045
A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the `triage` label
should be removed to prevent this automation from happening again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20402:
URL: https://github.com/apache/kafka/pull/20402#issuecomment-3942515457
This PR is being marked as stale since it has not had any activity in 90 days. If you
would like to keep this PR alive, please leave a comment asking for a review. If the PR has
merge conflicts, update it with the latest from the base branch.
<p>
If you are having difficulty finding a reviewer, please reach out on the
[mailing list](https://kafka.apache.org/contact).
<p>
If this PR is no longer valid or desired, please feel free to close it. If no activity
occurs in the next 30 days, it will be automatically closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20402:
URL: https://github.com/apache/kafka/pull/20402#issuecomment-4131543140
This PR has been closed since it has not had any activity in 120 days. If you feel like this
was a mistake, or you would like to continue working on it, please feel free to re-open the
PR and ask for a review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "ComingWen (via GitHub)" <gi...@apache.org>.
ComingWen commented on code in PR #20402:
URL: https://github.com/apache/kafka/pull/20402#discussion_r2434429837
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -293,12 +301,18 @@ public void configure(Map<String, ?> configs) {
final String type = simpleConfig.getString(TARGET_TYPE_CONFIG);
String formatPattern = simpleConfig.getString(FORMAT_CONFIG);
final String unixPrecision = simpleConfig.getString(UNIX_PRECISION_CONFIG);
+ final String time_zone = simpleConfig.getString(TIMEZONE_CONFIG);
schemaUpdateCache = new SynchronizedCache<>(new LRUCache<>(16));
replaceNullWithDefault = simpleConfig.getBoolean(REPLACE_NULL_WITH_DEFAULT_CONFIG);
if (type.equals(TYPE_STRING) && Utils.isBlank(formatPattern)) {
throw new ConfigException("TimestampConverter requires format option to be specified when using string timestamps");
}
+
+ if (!Utils.isBlank(time_zone)) {
+ UTC = TimeZone.getTimeZone(time_zone);
Review Comment:
Adjusted the code based on feedback,please review again,thank you very much !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "ComingWen (via GitHub)" <gi...@apache.org>.
ComingWen commented on code in PR #20402:
URL: https://github.com/apache/kafka/pull/20402#discussion_r2434429165
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -83,7 +86,8 @@ public abstract class TimestampConverter<R extends ConnectRecord<R>> implements
private static final String UNIX_PRECISION_NANOS = "nanoseconds";
private static final String UNIX_PRECISION_SECONDS = "seconds";
- private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
+ private static TimeZone UTC = TimeZone.getTimeZone("UTC");
+ //private static final TimeZone UTC = TimeZone.getTimeZone("Asia/Shanghai");
Review Comment:
Adjusted the code based on feedback,please review again,thank you very much !
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -92,6 +96,8 @@ public abstract class TimestampConverter<R extends ConnectRecord<R>> implements
public static final ConfigDef CONFIG_DEF = new ConfigDef()
.define(FIELD_CONFIG, ConfigDef.Type.STRING, FIELD_DEFAULT, ConfigDef.Importance.HIGH,
"The field containing the timestamp, or empty if the entire value is a timestamp")
+ .define(TIMEZONE_CONFIG, ConfigDef.Type.STRING, TIMEZONE_DEFAULT, ConfigDef.Importance.HIGH,
+ "The field containing the time_zone.")
Review Comment:
Adjusted the code based on feedback,please review again,thank you very much !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support to set the target timezone when we use the TimestampConverter. [kafka]
Posted by "ComingWen (via GitHub)" <gi...@apache.org>.
ComingWen commented on code in PR #20402:
URL: https://github.com/apache/kafka/pull/20402#discussion_r2434429522
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -271,16 +277,18 @@ public Date toType(Config config, Date orig) {
// This is a bit unusual, but allows the transformation config to be passed to static anonymous classes to customize
// their behavior
private static class Config {
- Config(String field, String type, SimpleDateFormat format, String unixPrecision) {
+ Config(String field, String type, SimpleDateFormat format, String unixPrecision, String time_zone) {
Review Comment:
Adjusted the code based on feedback,please review again,thank you very much !
##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java:
##########
@@ -271,16 +277,18 @@ public Date toType(Config config, Date orig) {
// This is a bit unusual, but allows the transformation config to be passed to static anonymous classes to customize
// their behavior
private static class Config {
- Config(String field, String type, SimpleDateFormat format, String unixPrecision) {
+ Config(String field, String type, SimpleDateFormat format, String unixPrecision, String time_zone) {
this.field = field;
this.type = type;
this.format = format;
this.unixPrecision = unixPrecision;
+ this.time_zone= time_zone;
Review Comment:
Adjusted the code based on feedback,please review again,thank you very much !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org