pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan del Rio Mendez <delrio.a...@gmail.com>
Subject Propose UDF
Date Sun, 01 Sep 2013 01:20:23 GMT
Hi Dev Team,

I developed a UDF to handle the following situation on pig 10.0 and want to
see if I could contribute with it to the project.

Let us consider a BAG "A" with the following data:

A:{record_id:{00001),names:{(ALAN),(SARAI)}},ids:{(00007),(00008)}}

and an expected bag "B"

B:{{record_id:(00001),name:(ALAN),
id:(00007)},{record_id:(00001),name:(SARAI), id:(00008)}}

Basically I propose a UDF "NLET" that takes N data bags containing the same
M elements each of them and creates M tuples with N fields and that is used
this way:

B = FOREACH A GENERATE record_id, FLATTEN(NLET(names,ids));

I tried to handle the situation described above using JOIN and RANK to
 join the databags, and even though it is not optimal it dind't work, when
using RANK for the join it generated runtime errors.

B1 = FOREACH A GENERATE record_id, FLATTEN(names);
B11 = RANK B1;
B2 = FOREACH A GENERATE FLATTEN(ids);
B22 = RANK B2;
C = JOIN B11 BY rank_B1 LEFT OUTER,B22 by rank_B2;  << Run time error

I spend some time reading the reference manual information:
    http://pig.apache.org/docs/r0.8.1/piglatin_ref2.html
    http://pig.apache.org/docs/r0.11.0/basic.html
and didn't identified a workaround to what I'm describing. I also read the
UDF manual http://wiki.apache.org/pig/UDFManual to develop the function
create the NLET UDF.

This far the UDF does generate the expected result/tuples but doesn't add
the schema information. If nobody has implemented this and it is worth to
approve, I can spend time on adding the schema information and proper
documentation.

PS. I'm starting to get involved into the community  and I will try to send
emails before future development starts to avoid duplicated efforts.

Best regards
Alan del Rio

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message