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 AA8E7DF18 for ; Tue, 11 Dec 2012 22:25:24 +0000 (UTC) Received: (qmail 39541 invoked by uid 500); 11 Dec 2012 22:25:23 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 39435 invoked by uid 500); 11 Dec 2012 22:25:22 -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 39422 invoked by uid 99); 11 Dec 2012 22:25:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2012 22:25:22 +0000 X-ASF-Spam-Status: No, hits=2.4 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of java8964@hotmail.com designates 65.55.116.91 as permitted sender) Received: from [65.55.116.91] (HELO blu0-omc3-s16.blu0.hotmail.com) (65.55.116.91) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2012 22:25:13 +0000 Received: from BLU162-W55 ([65.55.116.74]) by blu0-omc3-s16.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 11 Dec 2012 14:24:52 -0800 X-Originating-IP: [192.100.104.17] X-EIP: [OrNfVc5hxVhZt+foa9I3ieiO78k+Tk8i] X-Originating-Email: [java8964@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="_c0158b0f-e0e0-4d70-9531-283d71becc77_" From: java8964 java8964 To: Subject: Array index support non-constant expresssion Date: Tue, 11 Dec 2012 17:24:52 -0500 Importance: Normal In-Reply-To: References: MIME-Version: 1.0 X-OriginalArrivalTime: 11 Dec 2012 22:24:52.0492 (UTC) FILETIME=[56F864C0:01CDD7EE] X-Virus-Checked: Checked by ClamAV on apache.org --_c0158b0f-e0e0-4d70-9531-283d71becc77_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi=2C In our project to use the HIVE on CDH3U4 release (Hive 0.7.1)=2C I ha= ve a hive table like the following: Table foo ( search_results array> se= arch_clicks array>) As you can see=2C the 2nd column=2C which represents the list of search res= ults clicked=2C contains the index location of which results was clicked (s= tarting from 0). Now I need to find out the click count of some IDs=2C but = this IDs only exists in the search_result struct. When I tried to write a query for this=2C I will try to do following first: select search_results[c.index_loc] from foo lateral view explode(search_cli= cks) clickTable as c=3B But it won't work in hive=2C as the following error message returned:AILED:= Error in semantic analysis: Line 1:7 Non-constant expressions for array in= dexes not supported rank. It looks like that currently Hive (at least 0.7) does NOT support non-const= ant expressions as the array index. I searched on google=2C and found out the following HIVE jira ticket: https://issues.apache.org/jira/browse/HIVE-1955 It looks like someone has the same request to support it=2C but not yet. But there is a comment in the above ticket that it can be done in an UDF. M= y question is=2C can anyone share some ideas about how to archive this in a= n UDF=2C as it maybe the only option for me right now? Thanks = --_c0158b0f-e0e0-4d70-9531-283d71becc77_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi=2C In our project to use the HIVE on CDH3U4 release (Hive 0.7.1)=2C= I have a hive table like the following:

Table foo= (
 =3B  =3Bsearch_results array<=3Bstruct<=3Bid:bigi= nt=2C..............>=3B>=3B
 =3B  =3Bsearch_clicks ar= ray<=3Bstruct<=3Bindex_loc:int=2C ..............>=3B>=3B
= )

As you can see=2C the 2nd column=2C which repres= ents the list of search results clicked=2C contains the index location of w= hich results was clicked (starting from 0). Now I need to find out the clic= k count of some IDs=2C but this IDs only exists in the search_result struct= .

When I tried to write a query for this=2C I will= try to do following first:


select = search_results[c.index_loc] from foo lateral view explode(search_clicks) cl= ickTable as c=3B

But it won't work in hive=2C as t= he following error message returned:
AILED: Error in semantic ana= lysis: Line 1:7 Non-constant expressions for array indexes not supported ra= nk.

It looks like that currently Hive (at least 0.= 7) does NOT support non-constant expressions as the array index.
=
I searched on google=2C and found out the following HIVE jir= a ticket:

https://issues.apache.org/jira/browse/HIVE-1955

It looks like someone has the same request to support= it=2C but not yet.

But there is a comment in the = above ticket that it can be done in an UDF. My question is=2C can anyone sh= are some ideas about how to archive this in an UDF=2C as it maybe the only = option for me right now?

Thanks
<= /div> = --_c0158b0f-e0e0-4d70-9531-283d71becc77_--