Skip to content

KAFKA-13511: Add support for different unix precisions in TimestampConverter SMT#11575

Merged
mimaison merged 14 commits intoapache:trunkfrom
jchanaud:feat/KAFKA-13511
Feb 22, 2022
Merged

KAFKA-13511: Add support for different unix precisions in TimestampConverter SMT#11575
mimaison merged 14 commits intoapache:trunkfrom
jchanaud:feat/KAFKA-13511

Conversation

@jchanaud
Copy link
Contributor

@jchanaud jchanaud commented Dec 7, 2021

Currently, the SMT TimestampConverter can convert Timestamp from either source String, Long or Date into target String, Long or Date.

The problem is that Long source or target is required to be epoch in milliseconds.

In many cases, epoch is represented with different precisions. This leads to several Jira tickets :

KAFKA-12364: add support for date from int32 to timestampconverter
KAFKA-10561: Support microseconds precision for Timestamps
I propose to add a new config to TimestampConverter called "epoch.precision" which defaults to "millis" so as to not impact existing code, and allows for more precisions : seconds, millis, micros.

"transforms": "TimestampConverter",
"transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.TimestampConverter.field": "event_date",
"transforms.TimestampConverter.epoch.precision": "micros",
"transforms.TimestampConverter.target.type": "Timestamp"

Exactly like "format" field which is used as input when the source in String and output when the target.type is string, this new field would be used as input when the field is Long, and as output when the target.type is "unix"

Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@jchanaud
Copy link
Contributor Author

jchanaud commented Dec 7, 2021

@mimaison @rhauch before considering going further with this PR, any chance I could to get your opinion on this subject ?

The main idea behind this PR is that Avro logical types are not fully supported in Kafka Connect but even if they were, it would not help schema-less messages that need to convert epoch with a precision different than ms.

For this reason, I consider this would be an interesting addition.
Thanks for your help.

@mimaison
Copy link
Member

mimaison commented Dec 9, 2021

Hi @twobeeb, thanks for the PR, this looks like a useful addition. However as this is adding a new configuration, this change requires a KIP before we can accept it.
Take a look at https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Improvement+Proposals. This page details the KIP process. Let me know if you have any questions.

@mimaison mimaison added connect kip Requires or implements a KIP labels Dec 15, 2021
@jchanaud
Copy link
Contributor Author

Hi @mimaison,
I haven't received any update on the KIP-808 which I created as per your suggestion.

Could you be of any help ?

@mimaison
Copy link
Member

Sorry @twobeeb, I'll try to take a look this afternoon. Thanks

@jchanaud jchanaud changed the title KAFKA-13511: Update TimestampConverter support unix epoch as millis, micros, and seconds KAFKA-13511: Add support for different unix precisions in TimestampConverter SMT Jan 31, 2022
@jchanaud
Copy link
Contributor Author

Hi everyone,
Since KIP-808 is now adopted, could you review and comment this PR ?
Thanks

Copy link
Member

@tombentley tombentley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@jchanaud
Copy link
Contributor Author

@tombentley
Thanks for your inputs.
Regarding your last comment which I fixed, the same case could be made for target.type.
https://github.com/apache/kafka/blob/trunk/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java#L254-L257
Should we address this ? If so, this PR or new one ?

Copy link
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @twobeeb for the PR. It looks good, I just left a minor comment.

@mimaison
Copy link
Member

@tombentley Thanks for your inputs. Regarding your last comment which I fixed, the same case could be made for target.type. https://github.com/apache/kafka/blob/trunk/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java#L254-L257 Should we address this ? If so, this PR or new one ?

Yes feel free to address it in this PR if you want.

Copy link
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR!

@mimaison mimaison merged commit a5bb45c into apache:trunk Feb 22, 2022
yyu1993 added a commit to confluentinc/kafka that referenced this pull request Feb 25, 2022
* apache-kafka/trunk: (49 commits)
  KAFKA-12738: send LeaveGroup request when thread dies to optimize replacement time (apache#11801)
  MINOR: Skip fsync on parent directory to start Kafka on ZOS (apache#11793)
  KAFKA-12738: track processing errors and implement constant-time task backoff (apache#11787)
  MINOR: Cleanup admin creation logic in integration tests (apache#11790)
  KAFKA-10199: Add interface for state updater (apache#11499)
  KAFKA-10000: Utils methods for overriding user-supplied properties and dealing with Enum types (apache#11774)
  KAFKA-10000: Add new metrics for source task transactions (apache#11772)
  KAFKA-13676: Commit successfully processed tasks on error (apache#11791)
  KAFKA-13511: Add support for different unix precisions in TimestampConverter SMT (apache#11575)
  MINOR: Improve Connect docs (apache#11642)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connect kip Requires or implements a KIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants