Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.9.0, 1.10.0
-
None
Description
I have a simple avro schema as follows:
{ "type": "record", "name": "OfferUnderwritingDetailsEvent", "namespace": "com.ferozed.avro", "fields": [ { "name": "offerRequestId", "type": "string" }, { "name": "modifiedTimestamp", "type": "long", "logicalType": "date" } ] }
I use `avro-tools-1.9.0` to generate Java class from it:
java -jar ~/DevTools/avro-tools-1.9.0.jar compile -dateTimeLogicalTypeImpl joda schema logicalType.avsc .
When I look at the generated object, the type of the `setModifiedTimestamp` settor is still `int`. I would have expected `joda.time.Date` or something similar.
public long getModifiedTimestamp() { return modifiedTimestamp; } public com.ferozed.avro.OfferUnderwritingDetailsEvent.Builder setModifiedTimestamp(long value) { validate(fields()[1], value); this.modifiedTimestamp = value; fieldSetFlags()[1] = true; return this; }
When using 1.10.0 version of avro-tools, I dont even see the `dateTimeLogicalTypeImpl` option.
$ java -jar ~/DevTools/avro-tools-1.10.0.jar compile Usage: [-encoding <outputencoding>] [-string] [-bigDecimal] [-fieldVisibility <visibilityType>] [-templateDir <templateDir>] (schema|protocol) input... outputdir input - input files or directories outputdir - directory to write generated java -encoding <outputencoding> - set the encoding of output file(s) -string - use java.lang.String instead of Utf8 -fieldVisibility [private|public|public_deprecated]- use either and default private -bigDecimal - use java.math.BigDecimal for decimal type instead of java.nio.ByteBuffer -templateDir - directory with custom Velocity templates
And generating a java class using this schema generates the same object as the 1.9.0 toolset.
I also tried using `logicalType` with an `int` field, and it doesnt work.
Attachments
Attachments
Issue Links
- relates to
-
AVRO-3015 Java SchemaParser doesnt seem to honor logicalType annotation
- Resolved
- links to