Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig, mail # user - how to perform GROUP BY in PIG for this case:

yogesh dhari 2012-09-29, 22:02
Russell Jurney 2012-09-29, 23:15
yogesh dhari 2012-09-29, 23:32
Copy link to this message
Re: how to perform GROUP BY in PIG for this case:
Russell Jurney 2012-09-30, 02:21
My bad - you will need to register the Piggybank and jodatime jars. Replace
/me/pig with your pig install path.

register /me/pig/contrib/piggybank/java/piggybank.jar
register /me/pig/build/ivy/lib/Pig/joda-time-1.6.jar

define CustomFormatToISO

define ISOToMonth
That should take care of the error.

This example may help:

Russell Jurney http://datasyndrome.com

On Sep 29, 2012, at 4:33 PM, yogesh dhari <[EMAIL PROTECTED]> wrote:
Thanks Russell,

I am new to Pig. I have tried this command.
and got this exception.

2012-09-30 04:53:22,995 [main] ERROR org.apache.pig.tools.grunt.Grunt -
ERROR 1070: Could not resolve ISOToMonth using imports: [,
org.apache.pig.builtin., org.apache.pig.impl.builtin.]

Is there some thing more I need to do like import or some thing like that.

Please suggest.

Thanks & regards
Yogesh Kumar


Date: Sat, 29 Sep 2012 16:15:18 -0700

Subject: Re: how to perform GROUP BY in PIG for this case:

answer = foreach (group data by ISOToMonth(Date)) generate group as

month, MAX(data.rate) as max_rate;
Note, you will need your date in ISO8601 format, and you can use

CustomFormatToISO to convert it if it's is a string, or UnixToISO if

your date is a long.


Russell Jurney http://datasyndrome.com
On Sep 29, 2012, at 3:02 PM, yogesh dhari <[EMAIL PROTECTED]> wrote:
Hi all,
I have this data, having fields  (Date, symbol, rate)
and I want it to be group by Months, and to find out the maximum rate value
for each month.
like: for month (08, 36.3), (09, 36.4), (10, 36.8), (11, 37.5) ..
Please help and suggest .
Thanks & Regards
Yogesh Kumar
yogesh dhari 2012-09-30, 03:18
Russell Jurney 2012-09-30, 03:36
yogesh dhari 2012-09-30, 04:58