Search code examples
apache-pig

Pig map key to each value in a row, each row has various columns


In Apache Pig, the data looks like:

(1, ('a', 'b'))
(2, ('c'))
(3, ('d', 'e', 'f'))

How to transform it into:

(1, 'a')
(1, 'b')
(2, 'c')
(3, 'd')
(3, 'e')
(3, 'f')

Solution

  • You are looking for the FLATTEN operator in Pig. Have a look here for clear description with examples: https://pig.apache.org/docs/latest/basic.html#flatten