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

Switch to Plain View
Pig >> mail # dev >> Propose UDF

Alan del Rio Mendez 2013-09-01, 01:20
Copy link to this message
Re: Propose UDF
A few questions:

1) Why did you try to use RANK?  I don't see how rank is part of this.
2) The semantics here aren't clear to me.  record_id appears to be crossed with name and id but name and id appear to be chosen in order.  If this is join semantics I'd have expected two more entries in B, one with (1, Alan, 8) and one with (1, Sarai, 7).  If you were just taking each element in order I'd have expected the last row to be (null, Sarai, 8) instead.
3) I'm not familiar with the name NLET.  Does that refer to a particular function or algorithm?


On Aug 31, 2013, at 6:20 PM, Alan del Rio Mendez wrote:

> 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;
> 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
NOTICE: This message is intended for the use of the individual or entity to
which it is addressed and may contain information that is confidential,
privileged and exempt from disclosure under applicable law. If the reader
of this message is not the intended recipient, you are hereby notified that
any printing, copying, dissemination, distribution, disclosure or
forwarding of this communication is strictly prohibited. If you have
received this communication in error, please contact the sender immediately
and delete it from your system. Thank You.
Alan del Rio 2013-09-05, 21:51