This works for me (pig 0.6):

$ cat tmp/numbers
a    1    2
b    3    4
a    5    6
c    2    9
b    7    8
$ pig -x local
grunt> nums = load 'tmp/numbers' as (letter:chararray, x:int, y:int);
grunt> fract = foreach nums generate (double) x / y as div;
grunt> dump fract;
(0.5)
(0.75)
(0.8333333333333334)
(0.2222222222222222)
(0.875)


On Thu, Jul 15, 2010 at 3:35 PM, hc busy <[email protected]> wrote:

> if my table is:
>
> t = load 'data' as (v:int, c:int);
>
> and I want to do
>
> u = foreach t generate c/v as cov;
>
> how do I get fraction out of this? because
>
> u = foreach t generate (double)c / v;
>
> crashes with a casting error for me, do I write an UDF?
>

Reply via email to