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 Threaded View
Pig >> mail # user >> avoiding Group by or filter


Copy link to this message
-
Re: avoiding Group by or filter
Hi Preeti,

Using FILTER or not depends on your requirements and has nothing to do with
SUM or AVG.

SUM, AVG accept bags as input, so as long as you are able to provide that
it should be fine. (Though its very common that users use GROUP BY to
rollup on a key before using these UDFs).

For example:

grunt> cat data
1    5
5    8

grunt> A = load 'data';
grunt> B = foreach A generate TOBAG($0, $1) as bagg;
grunt> dump B;
({(1),(5)})
({(5),(8)})

grunt> C = foreach B generate AVG(bagg);
grunt> dump C;
(3.0)
(6.5)

-Prashant
On Mon, Mar 4, 2013 at 3:50 PM, Preeti Gupta <[EMAIL PROTECTED]>wrote:

> Hello,
>
> Can I compute SUM or AVG without using GROUPBY OR FILTER?
>
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