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

Scott Carey commented on AVRO-583:
----------------------------------

This error message confused me as well when first learning Avro.   The message 
led me in circles and does not point to what is wrong unless you already have a 
deeper understanding of Avro.

Note that what is wrong here is the _type_ , not the name, and to a beginner 
the first 'gut' response to that message is 'I set the name to "mymap", not 
"map", wtf?'.

If it said 'invalid name for type identifier, "map"' it would be better, or 
ideally something more informative about what is valid in that location and why.

The confusion for a beginner is that you see examples with fields like:

  {"name": "myfield", "type": "string" }

and so it makes sense to think that other built-in types work the same way, and 
so

   {"name": "mymap", "type": "map", "values": "string"} 

would work.

The current error message does nothing to inform the beginner that "map" and 
"array" are different than "string" and "int" etc.  one is a named type and the 
other is not.


I'm not sure how much context we have when this error is thrown to be more 
informative, but it should be easy to do better than the current message.


> Bad error message if you try and name an array or a map: 
> org.apache.avro.SchemaParseException: Undefined name: "map"
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-583
>                 URL: https://issues.apache.org/jira/browse/AVRO-583
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.3.2
>            Reporter: Sam Pullara
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> Error message should be something like "You can't name a map"
> Broken schema:
> {
>   "name":"annoyance",
>   "type":"record",
>   "fields":[
>     {
>       "name":"mymap",
>       "type":"map",
>       "values":"string"
>     }
>   ]
> }
> Error:
> org.apache.avro.SchemaParseException: Undefined name: "map"
>       at org.apache.avro.Schema.parse(Schema.java:876)
>       at org.apache.avro.Schema.parse(Schema.java:912)
>       at org.apache.avro.Schema.parse(Schema.java:796)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to