FAQ
Apologies Eric, I can't get it working either. Let me know if you figure it out.
Shane
On 8/10/07, Eric Palacios wrote:
Hi Shane,

Mmm did you try that ? Unfortunately PigLatin doesn't allow a query like '
A = ORDER Z BY $1 ; '. In fact , according with the docs it's necessary to
do :

A = FOREACH Z {
X = ORDER 'to_order' BY ....;

};

where 'to_order' has to be a bag (if i'm not wrong), and in my case there's
no bag to order.

In previous attempts i tried to group just by 'user' to later on use order
over the groupped bag :

(12 , {(12,145),(12,145),(12,133),(12,145)})
(13 , {(13,192),(13,164),(13,192)})

but i don't achieve to make a nested group in the already groupped bag , in
order to COUNT and finally order.

By the way , my SQL query had to say ORDER BY user,item,COUNT(*) DESC ,
but anyway i don't know how to solve both options.

I will keep trying ..

Thanks.

Eric.
On 8/10/07, Shane Butler wrote:

Hi Eric,

I think it will be something like A = ORDER Z BY .... (see pg 1 of
PigLatinAdvanced.pdf in the docs).

Cheers,
Shane
On 8/10/07, Eric Palacios wrote:
Hi all,

I'm trying to translate this simple query to PigLatin but i remain stuck in
the ordering.

Given this table :

(user,item)
12 145
13 192
12 145
12 133
13 164
13 192
12 145

i want to run this :

SELECT user,item,COUNT(*)
FROM table
GROUP BY user,item
ORDER BY COUNT(*) DESC



I tried this :

X = LOAD 'table.txt';
Y = GROUP X BY ($0,$1);
Z = FOREACH X GENERATE group,COUNT($1);

and i get this table:

((12,133),1)
((12,145),3)
((13,164),1)
((13,192),2)

but i have no clue how to flatten/group this to order it.

I hope this is the right mailing list to talk about Hadoop/Yahoo Pig stuff
Thanks in advance,

Eric.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 5 | next ›
Discussion Overview
groupcommon-user @
categorieshadoop
postedAug 9, '07 at 4:37p
activeAug 13, '07 at 11:34p
posts5
users3
websitehadoop.apache.org...
irc#hadoop

People

Translate

site design / logo © 2022 Grokbase