You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/12/11 19:08:04 UTC
[jira] [Commented] (AVRO-2065) Avro java code generation for Unions
doesn't set converters for unions
[ https://issues.apache.org/jira/browse/AVRO-2065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16717771#comment-16717771 ]
ASF subversion and git services commented on AVRO-2065:
-------------------------------------------------------
Commit 7ed38d7c7e150987ef8bf035196576fc158e03eb in avro's branch refs/heads/master from Katrin Skoglund
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=7ed38d7 ]
Improved conversions handling + pluggable conversions support [AVRO-1891, AVRO-2065] (#329)
* Added end-to-end test that reproduces union with logical types problem
* Adding required conversions to SpecificData in generated class
(same as in SpecificCompiler)
* Added test with BigDecimal
* Added test with BigDecimal
* Introduced customizable conversions in compiler and Maven plugin.
* Fixed bug
* Fixed Maven plugin classpath
* Get the correct SpecificData whenever possible, to get the right conversions
* No need to expose the map of conversions so expose only the values.
* Better tests
* Default values and conversions
* Cleanup of some changes in Maven plugin
* Fixed equals() for classes with nested logical types. Improved tests
* Added missing copyright statement
* Fixed compile error after rebase
* Fixed problem with logical types in nested records.
* Fixed failing test.
* Fixed serialization problem when creating SpecificDatumReader from a class
> Avro java code generation for Unions doesn't set converters for unions
> ----------------------------------------------------------------------
>
> Key: AVRO-2065
> URL: https://issues.apache.org/jira/browse/AVRO-2065
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.8.2
> Reporter: Stephane Maarek
> Priority: Blocker
> Fix For: 1.8.3
>
>
> The full issue is here: https://stackoverflow.com/questions/45581437/how-to-specify-converter-for-default-value-in-avro-union-logical-type-fields
> {code}
> {
> "name":"my_optional_date",
> "type":[
> {
> "type":"long",
> "logicalType":"timestamp-millis"
> },
> "null"
> ],
> "default":1502250227187
> }
> {code}
> Doesn't generate the right conversions
> {code}
> private static final org.apache.avro.Conversion<?>[] conversions =
> new org.apache.avro.Conversion<?>[] {
> null, // <------ THIS ONE IS NOT SET PROPERLY, should be TIMESTAMP_CONVERSION
> null
> };
> {code}
> The code fails on
> {code}
> BuggyRecord.Builder buggyRecordBuilder = BuggyRecord.newBuilder();
> buggyRecordBuilder.build();
> {code}
> with
> {code}
> org.apache.avro.AvroRuntimeException: java.lang.ClassCastException: java.lang.Long cannot be cast to org.joda.time.DateTime
> at com.example.BuggyRecord$Builder.build(BuggyRecord.java:301)
> at BuggyRecordTest.Foo(BuggyRecordTest.java:10)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
> at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to org.joda.time.DateTime
> at com.example.BuggyRecord$Builder.build(BuggyRecord.java:298)
> ... 23 more
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)