Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6534F2102 for ; Wed, 20 Apr 2011 00:06:08 +0000 (UTC) Received: (qmail 36463 invoked by uid 500); 20 Apr 2011 00:06:08 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 36428 invoked by uid 500); 20 Apr 2011 00:06:08 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 36421 invoked by uid 500); 20 Apr 2011 00:06:08 -0000 Delivered-To: apmail-hadoop-core-commits@hadoop.apache.org Received: (qmail 36418 invoked by uid 99); 20 Apr 2011 00:06:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Apr 2011 00:06:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Apr 2011 00:06:07 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 44A83CA0; Wed, 20 Apr 2011 00:05:47 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Wed, 20 Apr 2011 00:05:47 -0000 Message-ID: <20110420000547.52313.68338@eos.apache.org> Subject: =?utf-8?q?=5BHadoop_Wiki=5D_Update_of_=22Hive/LanguageManual/UDF=22_by_Ph?= =?utf-8?q?iloVivero?= Dear Wiki user, You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for ch= ange notification. The "Hive/LanguageManual/UDF" page has been changed by PhiloVivero. The comment on this change is: How to reformulate aggregation functions usi= ng subqueries. http://wiki.apache.org/hadoop/Hive/LanguageManual/UDF?action=3Ddiff&rev1=3D= 60&rev2=3D61 -------------------------------------------------- from log a lateral view json_tuple(a.appevent, 'eventid', 'eventname') b = as f1, f2; }}} = + =3D=3D=3D GROUPing and SORTing on f(column) =3D=3D=3D + = + If you would like to GROUP BY or SORT BY a column on which you've applied= a function, like this: + = + {{{ + select f(col) as fc, count(*) from table_name group by fc + }}} + = + You will get an error: + = + {{{ + FAILED: Error in semantic analysis: line 1:86 Invalid Table Alias or Colu= mn Reference fc + }}} + = + Because you are not able to GROUP BY or SORT BY a column on which a funct= ion has been applied. However, you can reformulate this query with subqueri= es: + = + {{{ + select sq.col,count(*) from (select f(column) as col) sq group by sq.col + }}} +=20