My requirement is to generate multiple lines of output by using single line of input in pig scripting. What are the possible solutions?
Asked
Active
Viewed 2,223 times
3
-
One solution is that I should use UDFs or streaming functionality of PIG to do this. – Ashish Jun 27 '12 at 10:49
1 Answers
7
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