Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating multiple lines output from single line input in pig

My requirement is to generate multiple lines of output by using single line of input in pig scripting. What are the possible solutions?

like image 937
Ashish Avatar asked Dec 06 '25 20:12

Ashish


1 Answers

The idea is to convert you input line into a bag and then flatten it. Here could be 2 cases:

Reading text:

txt = load '/pig_fun/input/text.txt' using TextLoader();
words = foreach txt generate TOKENIZE($0);
pivoted = foreach words generate FLATTEN($0);
dump pivoted;

Input:

My requirement is to generate multiple lines of output by using single line of input in pig scripting.
What are the possible solutions?

OUTPUT:

(My)
(requirement)
(is)
(to)
(generate)
(multiple)
(lines)
(of)
(output)
(by)
(using)
(single)
(line)
(of)
(input)
(in)
(pig)
(scripting.)
(What)
(are)
(the)
(possible)
(solutions?)

Reading columns and then pivoting them see Pivot table with Apache Pig

like image 194
alexeipab Avatar answered Dec 08 '25 12:12

alexeipab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!