[
https://issues.apache.org/jira/browse/AVRO-4184?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stephen Revilak updated AVRO-4184:
----------------------------------
Attachment: avro-4814-1.patch
Status: Patch Available (was: Open)
I'd like to offer a patch which addresses this issue, comes with a test, and
passes all of the tests in the lang/java directory (via {{{}mvn test{}}})
> Copying a decimal field with a default value produces a AvroTypeException
> -------------------------------------------------------------------------
>
> Key: AVRO-4184
> URL: https://issues.apache.org/jira/browse/AVRO-4184
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.12.0
> Reporter: Stephen Revilak
> Priority: Minor
> Attachments: AvroDemo.java, avro-4814-1.patch, pom.xml
>
>
> I'd like to report a regression in avro-1.12.0 where copying a decimal field
> with a default value results in a AvroTypeException being thrown.
> I've attached a minimal program that exhibits this behavior. To run,
> download the files pom.xml and AvroDemo.java. Then
> {noformat}
> mkdir -p src/main/java/srevilak/test
> mv AvroDemo.java src/main/java/srevilak/test
> mvn install
> java -cp 'target/*' srevilak.test.AvroDemo
> {noformat}
> It should produce the following output
> {noformat}
> copying field implicit_zscale type:BYTES pos:0
> Exception in thread "main" org.apache.avro.AvroTypeException: Invalid default
> for field implicit_zscale: "AA==" not a
> {"type":"bytes","logicalType":"decimal","precision":10}
> at org.apache.avro.Schema.validateDefault(Schema.java:1719)
> at org.apache.avro.Schema$Field.<init>(Schema.java:578)
> at org.apache.avro.Schema$Field.<init>(Schema.java:624)
> at srevilak.test.AvroDemo.main(AvroDemo.java:19)
> {noformat}
> I'm calling this a regression because the behavior was not present in
> avro-1.11.4. This can by verifed by
> * mvn clean
> * changing avro.version in pom.xml to 1.11.4
> * recompiling and running AvroDemo
> Under 1.11.4, the output is
> {noformat}
> copying field implicit_zscale type:BYTES pos:0
> SUCCESS
> {noformat}
> In 1.12.0, the parsed schema's default value is a TextNode. Copying the
> default value results in a BinaryNode that fails validation.
> I believe the regression was introduced in
> https://github.com/apache/avro/commit/51851d49af3283cd31caecf6bdc7b3a4e973a5a6
> Which was work done for AVRO-3876.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)