Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # dev >> STRSPLIT should return a bag rather than a tuple


Copy link to this message
-
STRSPLIT should return a bag rather than a tuple
Hi there,

I had a scenario, which required me to change the STRSPLIT code. The
scenario was as follows:

I have a data like:
1       A|1|1   some
2       B|2|2   data
3       C|3|3   hadoop
Need output like this :

1    A    some
1    1    some
1    1    some
2    B    data
2    2     data
2    2     data
3    C    hadoop
3    3    hadoop
3    3    hadoop

I was trying to use STRSPLIT($1,'\\|') which was returning a tuple, If I do
flatten on it, it converts the data into columns.

If we return a bag of tuples, we can easily use flatten() to convert it
into rows, plus can also convert that into Tuple using TOTUPLE() UDF (if
someone just want to use it as tuple.

Please suggest if this looks like a valid change. I am happy to file a JIRA
ticket and work accordingly on that.

Regards
Praveenesh