You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Kelvin Moss <km...@yahoo.com> on 2009/11/04 10:38:06 UTC

Casting to bag failure

Hi,

I have a file whose contents look like

{(1L),(2L),(3L)}
{(4L),(2L),(1L)}
{(8L),(3L),(4L)}

In short I want a bag with 3 tuples. I do the following to accomplish it
grunt> A = LOAD 'data1' as aa:bytearray;
grunt> FOREACH A GENERATE (bag{tuple(long),tuple(long),tuple(long)})aa;
2009-11-04 09:28:47,054 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Encountered " <IDENTIFIER> "FOREACH "" at line 1, column 1.
Was expecting one of:
    <EOF>
    "cat" ...
    "cd" ...
    "cp" ...
    "copyFromLocal" ...
    "copyToLocal" ...
    "dump" ...
    "describe" ...
    "aliases" ...
    "explain" ...
    "help" ...
    "kill" ...
    "ls" ...
    "mv" ...
    "mkdir" ...
    "pwd" ...
    "quit" ...
    "register" ...
    "rm" ...
    "rmf" ...
    "set" ...
    "illustrate" ...
    "run" ...
    "exec" ...
    "scriptDone" ...
    "" ...
    <EOL> ...
    ";" ...

What should be the syntax to cast?
 
Thanks!



      

Re: Casting to bag failure

Posted by Thejas Nair <te...@yahoo-inc.com>.
In 2nd line -
1. It is missing the identifier for the name of new relation (B = )
2. What you have is a bag of tuples of type integer. The number of instances
of the tuple in the bag does not matter for the schema (like array type in
java - int [] aa;)

Changing it to following should work -
B = FOREACH A GENERATE (bag{tuple(long)})aa;

-Thejas


On 11/4/09 2:38 AM, "Kelvin Moss" <km...@yahoo.com> wrote:

> Hi,
> 
> I have a file whose contents look like
> 
> {(1L),(2L),(3L)}
> {(4L),(2L),(1L)}
> {(8L),(3L),(4L)}
> 
> In short I want a bag with 3 tuples. I do the following to accomplish it
> grunt> A = LOAD 'data1' as aa:bytearray;
> grunt> FOREACH A GENERATE (bag{tuple(long),tuple(long),tuple(long)})aa;
> 2009-11-04 09:28:47,054 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR
> 1000: Error during parsing. Encountered " <IDENTIFIER> "FOREACH "" at line 1,
> column 1.
> Was expecting one of:
>     <EOF>
>     "cat" ...
>     "cd" ...
>     "cp" ...
>     "copyFromLocal" ...
>     "copyToLocal" ...
>     "dump" ...
>     "describe" ...
>     "aliases" ...
>     "explain" ...
>     "help" ...
>     "kill" ...
>     "ls" ...
>     "mv" ...
>     "mkdir" ...
>     "pwd" ...
>     "quit" ...
>     "register" ...
>     "rm" ...
>     "rmf" ...
>     "set" ...
>     "illustrate" ...
>     "run" ...
>     "exec" ...
>     "scriptDone" ...
>     "" ...
>     <EOL> ...
>     ";" ...
> 
> What should be the syntax to cast?
>  
> Thanks!
> 
> 
>