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

Scott commented on AVRO-3064:
-----------------------------

Your schema is not a valid schema on its own. I'm assuming this is just a 
snippet from a larger schema and the actual schema is something like this:


{code:java}
{
    "type": "record",
    "name": "some name",
    "fields": [
        {
            "name": "exacAmt",
            "type": [{"type": "fixed", "name": "exacAmt", "size": 16, 
"logicalType": "decimal", "precision": 38, "scale": 2}, "null"]
        }
    ]
}{code}
If that's the case, your data does not follow the JSON Encoding format. When a 
union is involved and the value is not null, the value must include the type 
information. You can see more details here: 
[https://avro.apache.org/docs/current/spec.html#json_encoding]

So in your case, the data should look like this:
{code:java}
{"exacAmt": {"exacAmt": "123.45"}}{code}
The first "exacAmt" is the field name, and the second one is the type 
information in the selected union.

> 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