My requirement is to generate multiple lines of output by using single line of input in pig scripting. What are the possible solutions?
3
votes
1 Answers
7
votes
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