apache pig - How to covert tuple to string in pig? -


i have data

id company 1  (a,b) 2  (a,c) 3  (f,g,h) 

company tuple, generate bagtotuple(sortedbag.company) company.

i remove formate of tuple, data looked following:

id company 1  b 2  c 3  f g h 

i company column has no brackets , separate space. thanks.

===================update

i have data set

id company 1  1  b 1  2  c 2  

i wrote code following: record = load....

grp = group record id;   newdata = foreach grp generate group id,          count(record) counts,          bagtotuple(record.company) company; 

the output looks like:

id count company 1  3     (a,b,a) 2  2     (c,a) 

but company can sorted , distinct, , no brackets, , divide space. expect result following:

id count company 1  3     b 2  2     c 

i think can replace bagtotuple bagtostring in last step:

newdata2 = foreach grp  generate group id, count(record) counts,      bagtostring(record.company, ' ') company:chararray;  store newdata2 outdir using pigstorage('#'); 

after script runs

$ cat outdir2/part-r-00000 1#3#a b 2#2#a c 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -