You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Marcio Silva (Updated) (JIRA)" <ji...@apache.org> on 2012/01/31 19:32:10 UTC

[jira] [Updated] (AVRO-973) Union behavior not consistent

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

Marcio Silva updated AVRO-973:
------------------------------

    Attachment: test_unions.py

Attached is a unit test that illustrates this issue.
                
> Union behavior not consistent
> -----------------------------
>
>                 Key: AVRO-973
>                 URL: https://issues.apache.org/jira/browse/AVRO-973
>             Project: Avro
>          Issue Type: Bug
>          Components: python
>            Reporter: Gaurav Nanda
>         Attachments: test_unions.py
>
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> Python's union does not respect the order in which type is specified.
> For following schema: {"type":"map","values":["int","long","float","double","string","boolean"]}, an integer value is written as double, but it should respect the order in which types have been specified.
> Fixed Code (io.py):
> def write_union(self, writers_schema, datum, encoder):
>    """
>    A union is encoded by first writing a long value indicating
>    the zero-based position within the union of the schema of its value.
>    The value is then encoded per the indicated schema within the union.
>    """
>    # resolve union
>    index_of_schema = -1
>    for i, candidate_schema in enumerate(writers_schema.schemas):
>      if validate(candidate_schema, datum):
>        index_of_schema = i
>        break // XXX Add break statement here XXX//
>    if index_of_schema < 0: raise AvroTypeException(writers_schema, datum)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira