hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Palacios" <epal...@gmail.com>
Subject How do you code this simple SQL query in PigLatin ?
Date Thu, 09 Aug 2007 16:36:57 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message