Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> accessing like array


+
jamal sasha 2012-11-06, 14:13
+
Mohammad Tariq 2012-11-06, 14:17
Copy link to this message
-
RE: accessing like array

Hi Jamal,

Have you followed Mohammad Tariq's steps?

Or else you can go like this,

A = load '/filename' using PigStorage(',') as (id, val1,val2);
B=foreach A generate id,val2;
C = group B by id;
D = foreach C generate flatten(B.id), MAX(B.val2);
E = distinct D;

Dump E;

Thanks & Regards
Yogesh Kumar Dhari
> From: [EMAIL PROTECTED]
> Date: Tue, 6 Nov 2012 19:47:55 +0530
> Subject: Re: accessing like array
> To: [EMAIL PROTECTED]
>
> load the data into a relation and use 'generate' to take only the required
> fields from this relation and put into some other relation..then store the
> 2nd relation into some file.
>
> Regards,
>     Mohammad Tariq
>
>
>
> On Tue, Nov 6, 2012 at 7:43 PM, jamal sasha <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >   I have data in form
> > 1,0.2,0.3
> > 1,0.3,0.4
> > 2,0.8,0.2
> > 2,0.9,0.7
> > and so on..
> > so id, va1,val2 format..
> >
> > This id is already sorted based on val 2
> > I want to select the 2nd element for each id with val2 (ignoring val1)
> > for example in the above dataset what i want to return is
> > 1,0.4
> > 2,0.7
> >
> > How to go about this??
> > Thanks
> >
     
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB