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
Alan Gates 2013-09-04, 16:05
Copy link to this message
Re: Propose UDF
Hi Alan,

Here are my answers:

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

{{record_id:(00001),rank_B1:(1),name:(ALAN)}, {record_id:(00001),

and then try to get something like this (two records):

using record_id and rank_B1,rank_B2 to join them. In short RANK gave
consecutive numbers for joining purposes. Like I mentioned it worked well
generating bags B11 and B22, but when I try to join them I got a run time
error during map reduce.

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
The problem that I'm dealing with is related to nested entries. The example
record (0001) contains a relation one to many with its attribute names and
besides that each name is associated to an id within the ids attribute. And
all this associations need to be dumped in a table with the following

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

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

3) I'm not familiar with the name NLET.Does that refer to a particular
function 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 N
because the function can generate sets of N number of items, depending on N
number of data bags , maybe I should just call it SET : P but didn't want
any issue with possible reserved words.

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

Best, Alan

On Wed, Sep 4, 2013 at 10:05 AM, Alan Gates <[EMAIL PROTECTED]> wrote:

> 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;