You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Andreas Paepcke <pa...@gmail.com> on 2011/01/03 00:30:47 UTC

Local Vars in FOREACH

Hi,

I'm confused by the following:


foo = FOREACH bar {
              theSize = COUNT(something);
              GENERATE mypack.myfunc(theSize);
              }

It seems that 'theSize' does not get typed, leading
to "java.lang.ClassCastException: java.lang.String cannot be cast to
org.apache.pig.data.DataBag"

When I replace 'theSize' in the myfunc() call
with a number (which myFunc() expects), all
works well. myFunc() gets called.

Where am I going wrong?

Thanks!

Andreas

Re: Local Vars in FOREACH

Posted by Dmitriy Ryaboy <dv...@gmail.com>.
What happens when you just go  "FOREACH bar GENERATE
mypack.myfunc(COUNT(something))" ?

On Sun, Jan 2, 2011 at 3:30 PM, Andreas Paepcke <pa...@gmail.com> wrote:

> Hi,
>
> I'm confused by the following:
>
>
> foo = FOREACH bar {
>              theSize = COUNT(something);
>              GENERATE mypack.myfunc(theSize);
>              }
>
> It seems that 'theSize' does not get typed, leading
> to "java.lang.ClassCastException: java.lang.String cannot be cast to
> org.apache.pig.data.DataBag"
>
> When I replace 'theSize' in the myfunc() call
> with a number (which myFunc() expects), all
> works well. myFunc() gets called.
>
> Where am I going wrong?
>
> Thanks!
>
> Andreas
>