[
https://issues.apache.org/jira/browse/AVRO-3015?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ryan Skraba resolved AVRO-3015.
-------------------------------
Resolution: Not A Bug
Hello – see AVRO-3014 for the related discussion.
The logicalType should be on the schema, not the field, and this is a common
and confusing mistake when writing a Schema in JSON.
{code:java}
{
"name": "modifiedDate",
"type": {"type": "int", "logicalType": "date"}
} {code}
> Java SchemaParser doesnt seem to honor logicalType annotation
> -------------------------------------------------------------
>
> Key: AVRO-3015
> URL: https://issues.apache.org/jira/browse/AVRO-3015
> Project: Apache Avro
> Issue Type: Bug
> Components: java, logical types
> Affects Versions: 1.9.0
> Reporter: Feroze Daud
> Priority: Major
> Attachments: Screen Shot 2020-12-29 at 7.06.36 PM.png
>
>
> I have a simple schema as follows:
> {noformat}
> {
> "type" : "record",
> "name" : "LogicalTypeDate",
> "namespace" : "com.zillow.avro",
> "fields" : [
> {
> "name" : "type",
> "type" : "string"
> }, {
> "name" : "modifiedDate",
> "type" : "int",
> "logicalType": "date"
> }
> ]
> } {noformat}
>
> I am reading it in java as follows:
> {noformat}
> org.apache.avro.Schema.Parser parser = new Schema.Parser();
> Schema schema =
> parser.parse(this.getClass().getClassLoader().getResourceAsStream(schemaFile));
> {noformat}
>
> When I look at the resultant *Schema* object, and look at the fields, I see
> "logicalType" is NULL for the "modifiedDate" field.
> I would have expected the field to be set correctly.
>
> Here is the image from the debugger window of my IntelliJ IDe
> !Screen Shot 2020-12-29 at 7.06.36 PM.png!
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)