You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by buping du <bu...@gmail.com> on 2009/12/17 21:14:44 UTC

top N

Hi:

Is there an easy way to get top N records based on a field value in pig
script? Thanks.

bp

Re: top N

Posted by zaki rahaman <za...@gmail.com>.
Not sure how it works in the unordered case... but when ordered, it should
return the first N elements. Can you highlight/explain the cases where it
doesn't work...

On Thu, Dec 17, 2009 at 5:29 PM, buping du <bu...@gmail.com> wrote:

> this does not work for me some times (some times it works). Is 'LIMIT'
> supposed to return the first N elements or a random N elements by design? I
> am using pig 0.4.
>
> bp
>
> On Thu, Dec 17, 2009 at 12:17 PM, zaki rahaman <zaki.rahaman@gmail.com
> >wrote:
>
> > Simplest way, order by field desc and then limit ordered relation to N.
> >
> > On Thu, Dec 17, 2009 at 3:14 PM, buping du <bu...@gmail.com> wrote:
> >
> > > Hi:
> > >
> > > Is there an easy way to get top N records based on a field value in pig
> > > script? Thanks.
> > >
> > > bp
> > >
> >
> >
> >
> > --
> > Zaki Rahaman
> >
>



-- 
Zaki Rahaman

Re: top N

Posted by buping du <bu...@gmail.com>.
this does not work for me some times (some times it works). Is 'LIMIT'
supposed to return the first N elements or a random N elements by design? I
am using pig 0.4.

bp

On Thu, Dec 17, 2009 at 12:17 PM, zaki rahaman <za...@gmail.com>wrote:

> Simplest way, order by field desc and then limit ordered relation to N.
>
> On Thu, Dec 17, 2009 at 3:14 PM, buping du <bu...@gmail.com> wrote:
>
> > Hi:
> >
> > Is there an easy way to get top N records based on a field value in pig
> > script? Thanks.
> >
> > bp
> >
>
>
>
> --
> Zaki Rahaman
>

Re: top N

Posted by zaki rahaman <za...@gmail.com>.
Simplest way, order by field desc and then limit ordered relation to N.

On Thu, Dec 17, 2009 at 3:14 PM, buping du <bu...@gmail.com> wrote:

> Hi:
>
> Is there an easy way to get top N records based on a field value in pig
> script? Thanks.
>
> bp
>



-- 
Zaki Rahaman