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 >> Pivot table with zeros instead of empty


Copy link to this message
-
Pivot table with zeros instead of empty
Hello!

I have a script that gives me following result:

time_grouped = GROUP joined BY (ip, hour);
counts = FOREACH time_grouped GENERATE group.ip as ip, group.hour as hour,
COUNT(joined) as count;

(128.187.97.22, 0, 180)
(128.187.97.22, 1, 84)
(128.187.97.22, 2, 25)
(128.187.97.22, 22, 31)
(128.187.97.22, 23, 2)

That is IP address, hour of day, counter.
I'd like to get following:

(128.187.97.22, (m1,m2, m3, ..., m23))
m1-m23 corresponds to the counter. And if there is nothing for particular
hour, then I'd like to have 0 instead empty value.

The trick here is that if I do not have anything for particular hour, then
I won't have count for it.
Is there a way to achieve the goal?

Thanks in advance
--
Evgeny Morozov
Developer Grid Dynamics
Skype: morozov.evgeny
www.griddynamics.com
[EMAIL PROTECTED]
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