Reputation: 2225
Does Apache Pig support an UNGROUP operation ? I guess No. So could any one help me out with this probblem? I have a rows of the form
1,a-b-c
2,d-e-f
3,g-h
I would like to expand it to the form
1,a
1,b
1,c
2,d
2,e
2,f
3,g
3,h
Any help appreciated.
Upvotes: 2
Views: 1021
Reputation: 41488
You should probably use the builtin STRSPLIT
to split your second field into several tokens, and then apply FLATTEN
to create 1 row per element. Something like this:
A = LOAD 'input.txt' as (id, data);
B = FOREACH A GENERATE id, FLATTEN(STRSPLIT(data,'-'));
Upvotes: 4