avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Hodges (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-531) ruby impl should produce better errors on "flattened" schemas in fields
Date Wed, 28 Apr 2010 08:01:38 GMT

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

Jeff Hodges commented on AVRO-531:

Note that we can't allow for this flattening on most types! 

This is unintuitive but allowing them all to be parsed as "flattened" leads to other problems.
Say we mean to define a FileMode type for the first time in the request field like so:

{"name": "mode", "type":{"name":"FileMode", "type": "enum", "symbols": ["w", "r"] }

but "flatten" the definition like the "bad" protocol given:

{"name": "mode",  "type": "enum", "symbols": ["w", "r"]}

This second schema is weird! We have the term "name" being overloaded! In the first one, we
have a field named "mode" that takes a type  named "FileMode" (remember that enum's require
names!). In the second one we have a field named "mode" and then some stuff that could be
creating an enum named "mode" but really is just incomplete!

This behavior is slightly confusing when dealing with array and map types, but is consistent
with the necessity to "nest" the named types enum, fixed, record, error and, of course, user-defined

Really, this problem is because people (like my fine coworkers!) are expecting types to behave
like the "simple" versions of primitive types (e.g. "string" instead of {"type": "string"})
when really they are much more than that! Hell, I've had to work on that myself!

So, again, we can't allow for this flattening because it is even more confusing than allowing
it! Ugh!

> ruby impl should produce better errors on "flattened" schemas in fields
> -----------------------------------------------------------------------
>                 Key: AVRO-531
>                 URL: https://issues.apache.org/jira/browse/AVRO-531
>             Project: Avro
>          Issue Type: Improvement
>          Components: ruby
>    Affects Versions: 1.3.2
>            Reporter: Jeff Hodges
>            Assignee: Jeff Hodges
> The "flattened" schemas of fields that look like
> {code}
> "request": [
>           { "name": "id", "type": "array", "items": "long" }
>         ],
> {code}
> that are supposed to be
> {code}
> "request": [
>           { "name": "id", "type": {"type": "array", "items": "long" }}
>         ],
> {code}
> should have way better errors associated with them. Basically, we should check record
types for things other than "default", "doc", "name", "type" and raise a specific error if
they are seen.

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

View raw message