Return-Path: X-Original-To: apmail-avro-user-archive@www.apache.org Delivered-To: apmail-avro-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CC5CC1012A for ; Fri, 5 Apr 2013 16:11:43 +0000 (UTC) Received: (qmail 65501 invoked by uid 500); 5 Apr 2013 16:11:43 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 65456 invoked by uid 500); 5 Apr 2013 16:11:43 -0000 Mailing-List: contact user-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@avro.apache.org Delivered-To: mailing list user@avro.apache.org Received: (qmail 65448 invoked by uid 99); 5 Apr 2013 16:11:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Apr 2013 16:11:43 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jcoveney@gmail.com designates 209.85.216.175 as permitted sender) Received: from [209.85.216.175] (HELO mail-qc0-f175.google.com) (209.85.216.175) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Apr 2013 16:11:37 +0000 Received: by mail-qc0-f175.google.com with SMTP id j3so1280398qcs.34 for ; Fri, 05 Apr 2013 09:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=WETw/YmXLQGV68Cgq8W/sYyIICV9ePOz//eDCsc58X4=; b=mXUC71yYgxqsxhSEzHi0u4jno+wV+/FZMqTJOi8QYVfXW63u9h/Xh8kUh90/Jl3GPT 7Sf1RWfLCTU8kz/JMqjxdqIDezWRrvzOj7+Kf1PyWuVJmupDgy6P0L50PqvnOPD+2516 NO/sBwRuCytcPZG2bZ422tEqJCW9ExUA4D7DMkCFPyEWWCnpDkb/6kEB4apoaDhIv/Xj PvPDi7RVgBX2MF9r1HZPUWsOIvdysOb5ul+JqwRa0NFynkHKmzSaJhg6XkzbfJ8w7ei3 vkCXPeVs0b37+jtTWFQhxqsPTEx10RuGWSOR1Is4z5qiPkJAV4L/RimTDkazKhw57Jmd 7Wfg== MIME-Version: 1.0 X-Received: by 10.229.115.30 with SMTP id g30mr3558197qcq.100.1365178276770; Fri, 05 Apr 2013 09:11:16 -0700 (PDT) Received: by 10.49.17.135 with HTTP; Fri, 5 Apr 2013 09:11:16 -0700 (PDT) Date: Fri, 5 Apr 2013 18:11:16 +0200 Message-ID: Subject: How is a union of multiple primitives handled? From: Jonathan Coveney To: user@avro.apache.org Content-Type: multipart/alternative; boundary=0023543338363e030004d99f56e9 X-Virus-Checked: Checked by ClamAV on apache.org --0023543338363e030004d99f56e9 Content-Type: text/plain; charset=UTF-8 The following gist illustrates my question: https://gist.github.com/jcoveney/5320422 It seems pretty surprising to me that all of these cases all return 1.0, at least in python (I will now do this in Java, it's just more verbose). Is this an issue with python? Is this an issue period? Is this unexpected? At the very least, if you write 1 to ["int", "double"] you'd expect that it'd get serialized as an int? Or is there a set of rules governing which primitive type to choose? Is it implementation dependent? Also, the case where it throws an error, then returns 0 seems completely wrong. Why would it do that at all? Is it that once it throws an error, it gets into an inconsistent state and nothing is guaranteed? Thanks for helping me understand this! --0023543338363e030004d99f56e9 Content-Type: text/html; charset=UTF-8
The following gist illustrates my question:

https://gist.github.com/jcoveney/5320422

It seems pretty surprising to me that all of these cases all return 1.0, at least in python (I will now do this in Java, it's just more verbose). Is this an issue with python? Is this an issue period? Is this unexpected?

At the very least, if you write 1 to ["int", "double"] you'd expect that it'd get serialized as an int? Or is there a set of rules governing which primitive type to choose? Is it implementation dependent?

Also, the case where it throws an error, then returns 0 seems completely wrong. Why would it do that at all? Is it that once it throws an error, it gets into an inconsistent state and nothing is guaranteed?

Thanks for helping me understand this!
--0023543338363e030004d99f56e9--