Lin Ma
Lin Ma

Reputation: 10139

strange error with DUMP in Pig

Here is my code and error, and using Pig on Hadoop, anyone have any good ideas? Thanks.

-- ({(3),(4),(1),(2),(7),(5),(6)},{(1),(3),(5),(12)})
A = load 'input.txt' AS (B1:bag{T:tuple(val:int)},B2:bag{T:tuple(val:int)});

DUMP A.B1;
DUMP A.B2;



[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Encountered " <PATH> "A.B1 "" at line 4, column 6.
Was expecting:
    <IDENTIFIER> ...

thanks in advance, Lin

Upvotes: 0

Views: 171

Answers (2)

steve
steve

Reputation: 31

Pig does not support the dump A.B1 and dump A.B2. here B1 ,B2 are bags in the realtion A.so.it's like two columns in the relation.we can not dump the columns of relation with "DUMP" operator.

if you want to perform any operation on columns of a relation,you can use FOREACH and GENERATE relational operators.

X = FOREACH A GENERATE B1.$0;

({(3),(4),(1),(2),(7),(5)})

Y = FOREACH A GENERATE B2.$0;

({(1),(3),(5),(12)})

Upvotes: 2

o-90
o-90

Reputation: 17593

Your problem is that DUMP A.B1 is not valid Pig syntax. If you want to only out put the first bag, B1 then you need to create a new relation that generates only that bag (and similarly for the second bag).

F1 = FOREACH A GENERATE B1;
F2 = FOREACH A GENERATE B2;

DUMP F1;
{(3),(4),(1),(2),(7),(5),(6)}

DUMP F2;
{(1),(3),(5),(12)}

Upvotes: 1

Related Questions