You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Jonathan Coveney <jc...@gmail.com> on 2013/04/05 18:06:02 UTC

How is a union of multiple primitives handled?

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!

Re: How is a union of multiple primitives handled?

Posted by Jonathan Coveney <jc...@gmail.com>.
woops, wrong listserv :)


2013/4/5 Jonathan Coveney <jc...@gmail.com>

> 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!
>