You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/05/19 11:35:00 UTC

[jira] [Updated] (AVRO-3130) Schema.java errors with "No type" when a type object is provided instead of text type

     [ https://issues.apache.org/jira/browse/AVRO-3130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated AVRO-3130:
---------------------------------
    Labels: pull-request-available  (was: )

> Schema.java errors with "No type" when a type object is provided instead of text type
> -------------------------------------------------------------------------------------
>
>                 Key: AVRO-3130
>                 URL: https://issues.apache.org/jira/browse/AVRO-3130
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>            Reporter: Aaron Zinger
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When a schema object is provided inside a union or as an array items type, the parser looks for a text value for type, doesn't find it, and throws a confusing error message of the form "No type: <thing with a type>".
> The error message could be fixed by having GetRequiredText distinguish between the key not being present and the value not being text, with the latter returning a message like "Value for type must be string".
> However, my preferred change would be to handle schema objects in these situations--it seems like it'd be compliant with the spec to have {"type": "string"} resolve to "string", and it would let schema generation code be a little simpler by letting it reuse schemas. This could also address https://issues.apache.org/jira/browse/AVRO-1977, I think.
> Examples below.
> {code:json}
> {
>     "type": "record",
>     "name": "AccountEvent",
>     "fields": [
>         {"type": 
>           ["null",
>            { "name": "accountList",
>               "type": {
>                 "type": "array",
>                 "items": "long"
>               }
>           }
>           ], 
>          "name":"NullableLongArray"
>        }
>     ]
> }
> {code}
> Fails with {code:java}"No type: {\"name\":\"accountList\",\"type\":{\"type\":\"array\",\"items\":\"long\"}}"{code}
> The error is similar for
> {code:json}
> {
>     "type": "array",
>     "name": "FavoriteNumbers",
>     "items": {"type":{"type": ["null","long"], "name": "NullableNumber"}}
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)