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

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

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?

Alan.

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;> 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-- CONFIDENTIALITY NOTICENOTICE: 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.

1) Why did you try to use RANK?I needed to create a second attribute in order to generate a one to onerelationship between the two data bags, names and ids. RANK allowed me togenerate a unique sequence per data bag item according to the tupleposition within the bags after using FLATTEN so that I could have thefollowing:

and then try to get something like this (two records):{ {record_id:(00001),name:(ALAN),id:(00007)}, {record_id:(00001),name:(SARAI),id:(00008)}}

using record_id and rank_B1,rank_B2 to join them. In short RANK gaveconsecutive numbers for joining purposes. Like I mentioned it worked wellgenerating bags B11 and B22, but when I try to join them I got a run timeerror during map reduce.

2) The semantics here aren't clear to me. record_id appears to be crossedwith name and id but name and id appear to be chosen in orderThe problem that I'm dealing with is related to nested entries. The examplerecord (0001) contains a relation one to many with its attribute names andbesides that each name is associated to an id within the ids attribute. Andall this associations need to be dumped in a table with the followingstructure.

record_id-------name_id (id)--------name.

This is not cross semantics, actually I had to develop the NLET function toavoid a cross product. Considering that the example record should onlyoutput 2 records. Number of records = 1 * number of items within the databag (ids or names ,which is the same number).

3) I'm not familiar with the name NLET.Does that refer to a particularfunction or algorithm?Not really, I just wanted something that could sound similar to the word"TRIPLET" which refers to a set of items I replaced TRIP with the letter Nbecause the function can generate sets of N number of items, depending on Nnumber of data bags , maybe I should just call it SET : P but didn't wantany issue with possible reserved words.

By the way the data source of the bag A is a record that uses JSON whereit is common to see this kind of nested data.

> 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?>> Alan.>> 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;> > B2 = FOREACH A GENERATE FLATTEN(ids);

+

Alan del Rio 2013-09-05, 21:51

NEW: Monitor These Apps!

All projects made searchable here are trademarks of the Apache Software Foundation.
Service operated by Sematext