You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Amjad ALSHABANI <as...@gmail.com> on 2014/01/31 17:38:00 UTC
Multiple group-by Inserts
Hello ,
I m trying to get some statistics using Hive and insert them into new table
Those statics are the count of each field on another table grouped by the
column "usrlvl"
I need to do all of that in single request, so I ve googled how to do that
and found the following link
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+GroupBy
The problem is that I need to do multiple INSERT based on SELECT/GROUP BY
the same column
In detalied I m trying to do the following:
USE pns_fr_integ; FROM cust t JOIN core m ON (t.ise=m.ise)
INSERT OVERWRITE TABLE pns_stats.detailed PARTITION
(ks='pns_fr_integ',tbl='cust',field='mbilllist',type='usrlvl',hive_date='2014-01-31')
SELECT 'Total nu;ber of wele;ents grouped by usrlvl for the field mbilllist
in the table cust (pns_fr_integ)', count(t.ise), m.usrlvl, '' WHERE
t.mbilllist <> '' AND m.usrlvl in (0,1,2,5) GROUP BY m.usrlvl
INSERT OVERWRITE TABLE pns_stats.detailed PARTITION
(ks='pns_fr_integ',tbl='cust',field='idavatar2',type='usrlvl',hive_date='2014-01-31')
SELECT 'Nombre total d elements groupe par usrlvl pour le champ idavatar2
(different de \'\') dans la table cust (pns_fr_integ)', count(t.ise),
m.usrlvl, '' WHERE t.idavatar2 <> '' AND m.usrlvl in (0,1,2,5) GROUP BY
m.usrlvl
(I ve tried this request using $sudo hive -e and it gave me an error about
the group by)
I ve learned from the link above that when using Multi-Groub-By the output
of the aggregation is sent further into multiple table, but actually I do
not want it to be sent to the next INSERT statement
Any idea about how to prevent the output from first GROUP BY to be sent to
the second one
Cheers