hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Himanish Kushary <himan...@gmail.com>
Subject Aggregate data into map data type values
Date Thu, 18 Oct 2012 21:42:56 GMT
Hi,

I have a table (Table A) with the following data :

name    pid    pflag    pstr  count
========================
ABC    502 01 0000   1
ABC    502 01 0010   2
ABC    502 01 0020   2
DEF    504 01 0101   1
GHI    502 00 0000   1

I want to put this data into another table(Table B) so that the data looks
like :

name  pid   pflag    pstrcount
==================================
ABC   502   01     {"0000":1;"0010":2;"0020":2}
DEF   504   01     {"0101":1}
GHI   502   00       {"0000":1}

So pstrcount column is a map of the pstr and count from the Table A.

Do I need to write custom UDAF to get this done or is there any way
to achieve this out of the box using some Hive function/construct etc.

I tried this query :

create table B stored as sequencefile
as
select name,pid,pflag,map(pstr,count) as pstrcount from A;

but got this output :

ABC 502 01 {"0000":1}
ABC 502 01 {"0010":2}
ABC 502 01 {"0020":2}
DEF 504 01 {"0101":1}
GHI 502 00 {"0000":1}

Could somebody please help.

-- 
Thanks & Regards
Himanish

Mime
View raw message