Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB4D6D864 for ; Thu, 18 Oct 2012 21:43:26 +0000 (UTC) Received: (qmail 71469 invoked by uid 500); 18 Oct 2012 21:43:25 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 71407 invoked by uid 500); 18 Oct 2012 21:43:25 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 71393 invoked by uid 99); 18 Oct 2012 21:43:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Oct 2012 21:43:25 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of himanish@gmail.com designates 209.85.220.176 as permitted sender) Received: from [209.85.220.176] (HELO mail-vc0-f176.google.com) (209.85.220.176) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Oct 2012 21:43:17 +0000 Received: by mail-vc0-f176.google.com with SMTP id gb22so11937870vcb.35 for ; Thu, 18 Oct 2012 14:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=OJMiw7yfD20m+H/qEfiS91NmVZk6zdhsOScOy/M0xTU=; b=HEue+vEUgQLLRcWR3+4his/CweFEdc3iWrLieOneuJMcSA2CXzveAzZqZAg6XV7T8n ZWHEeR8JiEkuxAMpmG05Us5UK5lA6kLME5baOjEX/oPo/JaXhsv8CCjFoIC4hC1DXi5l rYg3dy2QtNJg56YsTElcJIYqLcFYraW7uGloyqj9PL3Oc6qTwbpaPlMNR9bO2/8tx627 pM9Cu3/Cqx8UB9A0NfXyHlbv4VZoK67GGRZHIyRRxjgmc1eExUMRhK9flxMsk7+/7bpQ 7tR30jg/wse8N1DN4zRLUxX6FcyE6aZS/nOJsLyqeNhObwosMY43RmqxCRbWkYL2skrq rVLQ== MIME-Version: 1.0 Received: by 10.58.94.44 with SMTP id cz12mr18145301veb.34.1350596576181; Thu, 18 Oct 2012 14:42:56 -0700 (PDT) Received: by 10.58.75.200 with HTTP; Thu, 18 Oct 2012 14:42:56 -0700 (PDT) Date: Thu, 18 Oct 2012 17:42:56 -0400 Message-ID: Subject: Aggregate data into map data type values From: Himanish Kushary To: user@hive.apache.org Content-Type: multipart/alternative; boundary=047d7b6dcaf0287ee704cc5c45da X-Virus-Checked: Checked by ClamAV on apache.org --047d7b6dcaf0287ee704cc5c45da Content-Type: text/plain; charset=ISO-8859-1 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 --047d7b6dcaf0287ee704cc5c45da Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

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

name =A0 =A0pid =A0 =A0pflag =A0 =A0pstr =A0co= unt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D
ABC =A0 =A0502 01= 0000 =A0=A01
ABC = =A0 =A0502 = 01 0010 =A0=A02
ABC = =A0 =A0502 = 01 0020 =A0= =A02
DEF= =A0 =A0504= 01 = 0101 =A0=A0= 1
GHI = =A0 =A0502 = 00 0000 =A0=A01

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

name =A0pid =A0 pflag = =A0 =A0pstrcount
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
ABC =A0=A0502 =A0=A001 =A0 =A0=A0{&quo= t;0000":1;"0010":2;"0020":2}
DEF = =A0=A0504 = =A0=A001 = =A0 =A0=A0{"0101":1}
GHI = =A0=A0502 = =A0=A000 =A0 =A0 =A0 {"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 t= here any way to=A0achieve=A0this out of the box using some Hive function/co= nstruct etc.

I tried this query :=A0
create table B stored as sequencefile
as
select na= me,pid,pflag,map(pstr,count) as pstrcount from A;=A0

but got this output :

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

Could somebody please help.

-= -
Thanks & Regards
Himanish
--047d7b6dcaf0287ee704cc5c45da--