[ 
https://issues.apache.org/jira/browse/AVRO-3064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17298794#comment-17298794
 ] 

Ryan Skraba commented on AVRO-3064:
-----------------------------------

 [~scottbelden] is completely correct, but you'll need to use the Avro JSON 
encoding of binary data (the underlying fixed buffer as described in 
AVRO-3050), not the String representation of the decimal:

{code}
{"exacAmt":{"exacAmt":"\u0000\u0000\u0000\u0000\u0000\u0003\u0019vzu•1œ@\u0000"}}
{code}

Or if the field is null:

{code}
{"exacAmt":null}
{code}

As Scott mentioned, AVRO-1582 would be a new feature that would help make the 
AVRO JSON encoding be a bit more human-readable.  The specification is 
unambiguous and maps nicely to Avro binary, but it's pretty rigid and 
occasionally you get "surprising" structures around unions, like the one above.

In my experience, if you're trying to use Avro to parse JSON that did not come 
from an Avro JSONEncoder (from any language SDK), you're in for a difficult 
time.  If you're trying to use Avro to generate JSON in a format that you want 
(outside of the spec), you're unlikely to be happy either!

> Issue: Unknown union branch fixed
> ---------------------------------
>
>                 Key: AVRO-3064
>                 URL: https://issues.apache.org/jira/browse/AVRO-3064
>             Project: Apache Avro
>          Issue Type: Task
>          Components: java
>    Affects Versions: 1.8.0
>            Reporter: Divya
>            Priority: Major
>         Attachments: Screenshot from 2021-03-04 21-19-06.png
>
>
> Hello,
>  
> We are looking for documentation on how a fixed value can be used with null.
> We are using avro-1.8.0 and trying to generate a Decimal value with the help 
> of JSONDecoder for schema:
>         {
>             "name": "exacAmt",
>             "type": [
>                 {
>                     "type": "fixed",
>                     "name": "exacAmt",
>                     "size": 16,
>                     "logicalType": "decimal",
>                     "precision": 38,
>                     "scale": 2
>                 },
>                 "null"
>             ]
>         }
> But we are getting an exception:
> _Message: Unknown union branch fixed_
>  _Line | Method_
>  _->> 445 | readIndex in org.apache.avro.io.JsonDecoder_
>  
> Please advise how can this issue be resolved.
> !Screenshot from 2021-03-04 21-19-06.png!
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to