Hi Elliot,

I also came across this inconvenience. I’m using 
`field.schema.getProp(LogicalType.LOGICAL_TYPE_PROP)` for that.
This one is not deprecated.

Are you using predefined logical types or custom ones?
I would expect the predefined ones to be retrievable with 
`field.schema().getLogicalType().getName()`.

In the referenced post the JSON was also not really correctly formatted I think.
I think It should have been the below… wrapping the logic type related things 
in yet another set of curly braces.

{
 "namespace": "example.avro",
 "type": "record",
 "name": "User",
 "fields": [
     {
       "name": "name", "type": "string"
     },
     {
       "name": "account_balance",
       "type":
       {
         "type": "bytes",
         "logicalType": "decimal",
         "precision": 4,
         "scale": 2
       }
     }
 ]
}

Regards,
Pieter

From: Elliot Crosby-McCullough [mailto:[email protected]]
Sent: woensdag 29 maart 2017 16:37
To: [email protected]
Subject: Parsed JSON schemas not incorporating logical types

Hi,

As noted in this thread from last year[1], Avro seems not to incorporate the 
logical types of fields when parsing JSON files.

This means that instead of using `field.schema().getLogicalType().getName()` I 
have to use the deprecated `field.props().get("logicalType")` (where `field` is 
a `Schema.Field` retrieved via the record's `schema.getFields()` method).

Any idea why this might be the case?  I'm using Avro 1.8.1 for this.

Regards,
Elliot

[1] 
http://apache-avro.679487.n3.nabble.com/Decimal-types-in-IDL-and-generated-Java-not-carrying-logical-types-to-schemas-td4034919.html

Reply via email to