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

Sergei Kuzmin commented on AVRO-1291:
-------------------------------------

Changes in schema.py ensure that all schemas (including Primitive) now have 
fullname which one can access. Useful for special processing.
Changes in validate() are to report particular sub-entity with error. Very 
useful in hierarchical records where some internal item has problem.
Having this functionality is a way more logical:
1) compatibility with current clients who make use of the current datum
2) possibility to use strict JSON style datum which allows to unambiguously map 
avro blob<->memory (which is currently not the case).
3) possibility to map into Pegasus style datum which is a way nicer than (2), 
still allows unambiguous mapping, and doesn't require you to specify type then 
accessing simple optional field.
Assume this (writing in pseudo syntax):
Person = { name: string, alias: [null, string], comment:[null, string]} // 
alias is optional field/union with null
Business = {name: string, alias: [null, string], comment:[null, string]} // 
alias and founder are optional
Entity = [null, Person, Business] // union with multiple types
Then we have instance of Person "Vasya" with alias "Pupkin" and empty comment.
Strict datum (for json just do json.dumps): { "Person" : {"name": "Vasya", 
"alias" : {"string": "Pupkin"}, "comment": None}}, access: 
entry["Person"]["alias"]["string"] -> "Pupkin"
Current datum : {"name": "Vasya", alias: "Pupkin", "comment": None} - no way to 
understand is it Person or Business. Access: entry["alias"] -> "Pupking"
Pegasus style: {"Person" : { "name" : "Vasya", "alias": "Pupkin"}}. "Person" 
identifies the class, no need to specify "string" for an alias (just an 
optional field). Comment has default value, so not present in the map. Access: 
entry["Person"]["alias"] -> "Pupkin"


> Python library missing strict JSON encode/decoe
> -----------------------------------------------
>
>                 Key: AVRO-1291
>                 URL: https://issues.apache.org/jira/browse/AVRO-1291
>             Project: Avro
>          Issue Type: Bug
>          Components: python
>    Affects Versions: 1.7.7
>            Reporter: Jeremy Kahn
>         Attachments: avro.diff
>
>
> The Python Avro libraries don't actually have a proper JSON decoder or 
> encoder, because they don't handle the [type-hinting for 
> unions|http://avro.apache.org/docs/current/spec.html#json_encoding] properly.
> The Python {{avro.io}} library should provide a pair of 
> {{StrictJsonEncoder,StrictJsonDecoder}}} classes that correctly include (and 
> decode) the type hints when the schema expects a union.
> Jonathan Coveney [raised this 
> concern|http://mail-archives.apache.org/mod_mbox/avro-user/201304.mbox/%3CCAKne9Z6nkYXwb4QzPr4qNyH1o7TnL1674MspgnHuKMuD2imguQ%40mail.gmail.com%3E]
>  on the Avro User mailing list.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to