Skip to content

Conversation

@opwvhk
Copy link
Contributor

@opwvhk opwvhk commented Sep 25, 2023

What is the purpose of the change

Add logical type and conversion for "Duration", in the context of AVRO-2123

This is an alternative implementation for PR #1263.

Core in this change is a new implementation of java.time.TemporalAmount, which combines functionality of both java.time.Period and java.time.Duration. This is needed to cleanly implement the logical type.

Verifying this change

This change adds tests for all changed functionality:

  • org.apache.avro.util.TimePeriodTest
  • org.apache.avro.TestLogicalType#durationExtendsFixed12
  • org.apache.avro.generic.TestGenericLogicalTypes#readWriteDuration
  • org.apache.avro.TestLogicalType#uuidExtendsString (boyscout refactoring)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

This adds a new `java.time.TemporalAmount` implementation, which
supports the Avro `duration` logical type (neither `java.time.Period`
nor `java.time.Duration` support it).
Also refactors logical type "uuid" to include validation.
@github-actions github-actions bot added the Java Pull Requests for Java binding label Sep 25, 2023
Copy link
Contributor

@clesaec clesaec left a comment

Choose a reason for hiding this comment

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

LGTM

@opwvhk opwvhk merged commit abe6d42 into apache:master Oct 5, 2023
@opwvhk opwvhk deleted the AVRO-2123-Java-duration-logical-type branch October 5, 2023 08:38
RanbirK pushed a commit to RanbirK/avro that referenced this pull request May 13, 2024
This adds a new `java.time.TemporalAmount` implementation, which
supports the Avro `duration` logical type (neither `java.time.Period`
nor `java.time.Duration` support it).

This type is then used in the conversion for the (new) logical type
implementation "duration".

Last, the logical type "uuid" is refactored to include validation.
@GFriedrich
Copy link

Hello @opwvhk,
first of all thanks for adding the duration support for the Java implementation.
Unfortunately I found that it is incomplete. (for more details see AVRO-4159)
Side note: The declined PR of #1263 contained this piece of code, but it seems it was missed to keep that.

@opwvhk
Copy link
Contributor Author

opwvhk commented Jun 27, 2025

Thank you for pointing this out, @GFriedrich!

I've opened a new PR (#3416) to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants