Search code examples
apache-pigbag

Pig: extract all values of a bag?


I want to extract all values from a bag. What I mean is:

DESCRIBE x;
x: {data: (id: long, value: long)}

y = (WHAT DO I DO HERE?)

DESCRIBE y;
y: {id: long, value: long}

I've tried the wildcard operator and project-range expressions, but they don't work

y = foreach x generate data.*;                       
ERROR 1200: Syntax error, unexpected symbol at or near '*'

y = foreach x generate data.($0 ..);                       
ERROR 1200: mismatched input '..' expecting RIGHT_PAREN

How do I...?


Solution

  • Try to use FLATTEN operator.

    FOREACH X GENERATE FLATTEN(data);
    

    If this FLATTEN doesn't work, paste your input values, i will help you.