kk415kk
kk415kk

Reputation: 1247

"Flattening" a databag in Pig

Suppose I have a bunch of databags generated from a Pig UDF that holds several tuples of Strings. How can I pull all of them out of the databags and simple make each String its own "row" of data.

databags = FOREACH data GENERATE pigUdfThatMakesDataBags(data::someText); strings = FOREACH databags { ??? };

Upvotes: 0

Views: 300

Answers (2)

nobody
nobody

Reputation: 11080

databags = FOREACH data GENERATE pigUdfThatMakesDataBags(data::someText);
datatuples = FOREACH databags FLATTEN($0);      -- Bag to Tuples 
strings = FOREACH datatuples FLATTEN(TOBAG(*)); -- Tuples to Tokens'
DUMP strings;

Upvotes: 1

kecso
kecso

Reputation: 2485

Am I understand it right that you're looking for the FLATTEN?

Upvotes: 1

Related Questions