-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[WIP][BEAM-8715] Bump Avro version to 1.9.2 #17372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| */ | ||
| package org.apache.beam.sdk.values; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -128,6 +129,14 @@ private <T> T getValue(FieldType type, Object fieldValue, @Nullable Integer cach | |
| cachedMaps.computeIfAbsent( | ||
| cacheKey, i -> getMapValue(type.getMapKeyType(), type.getMapValueType(), map)) | ||
| : (T) getMapValue(type.getMapKeyType(), type.getMapValueType(), map); | ||
| } else if (type.getTypeName().equals(TypeName.DATETIME)) { | ||
| if (fieldValue instanceof java.time.LocalDate) { | ||
| Instant instant = java.time.Instant.parse(fieldValue + "T00:00:00.00Z"); | ||
| return (T) org.joda.time.Instant.ofEpochMilli(instant.toEpochMilli()); | ||
| } else if (fieldValue instanceof java.time.Instant) { | ||
| return (T) org.joda.time.Instant.ofEpochMilli(((Instant) fieldValue).toEpochMilli()); | ||
| } | ||
| return (T) fieldValue; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this logic should be in the Avro getters, instead of branching on this instance check.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it's related to only Avro case but since Beam schema uses joda time internally then java time should be converted in any case until we won't switch to java time (if we will, of course).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aromanenko-dev I think @TheNeuralBit is right. Based on benchmarks I've done just recently, branching in The For Avro there's already a conversion layer in place you could leverage for that. For |
||
| } else { | ||
| if (type.isLogicalType(OneOfType.IDENTIFIER)) { | ||
| OneOfType oneOfType = type.getLogicalType(OneOfType.class); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,7 +121,6 @@ public void testGcpApiSurface() throws Exception { | |
| classesInPackage("org.apache.avro"), | ||
| classesInPackage("org.apache.beam"), | ||
| classesInPackage("org.apache.commons.logging"), | ||
| classesInPackage("org.codehaus.jackson"), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not an Avro's dependency anymore . |
||
| classesInPackage("org.joda.time"), | ||
| Matchers.<Class<?>>equalTo(org.threeten.bp.Duration.class), | ||
| Matchers.<Class<?>>equalTo(org.threeten.bp.format.ResolverStyle.class), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to add this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because starting from Avro 1.9.0 this dependency became
providedbut we need this for tests