Return-Path: Delivered-To: apmail-hadoop-hive-dev-archive@minotaur.apache.org Received: (qmail 34760 invoked from network); 24 Mar 2009 19:48:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Mar 2009 19:48:13 -0000 Received: (qmail 98100 invoked by uid 500); 24 Mar 2009 19:48:13 -0000 Delivered-To: apmail-hadoop-hive-dev-archive@hadoop.apache.org Received: (qmail 98077 invoked by uid 500); 24 Mar 2009 19:48:13 -0000 Mailing-List: contact hive-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hadoop.apache.org Delivered-To: mailing list hive-dev@hadoop.apache.org Received: (qmail 98067 invoked by uid 99); 24 Mar 2009 19:48:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Mar 2009 19:48:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Mar 2009 19:48:11 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B6A53234C041 for ; Tue, 24 Mar 2009 12:47:50 -0700 (PDT) Message-ID: <595821146.1237924070747.JavaMail.jira@brutus> Date: Tue, 24 Mar 2009 12:47:50 -0700 (PDT) From: "Raghotham Murthy (JIRA)" To: hive-dev@hadoop.apache.org Subject: [jira] Issue Comment Edited: (HIVE-362) avg() returns null if any item in the list is null; create function that doesn't In-Reply-To: <5644619.1237916512114.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HIVE-362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12688827#action_12688827 ] Raghotham Murthy edited comment on HIVE-362 at 3/24/09 12:47 PM: ----------------------------------------------------------------- In your example, even with NULLs, SUM(a) / COUNT(a) will be the same as AVG(a). This is because COUNT(a) returns the number of rows which have non-null 'a'. This is different from COUNT(1) which returns the count of all rows. was (Author: rsm): In your example, even with NULLs, SUM(a) / COUNT(a) will be the same as AVG(a). This is because COUNT(a) returns the number of rows which have non-null 'a'. This is different from COUNT(*) which returns the count of all rows. > avg() returns null if any item in the list is null; create function that doesn't > -------------------------------------------------------------------------------- > > Key: HIVE-362 > URL: https://issues.apache.org/jira/browse/HIVE-362 > Project: Hadoop Hive > Issue Type: Bug > Components: Query Processor > Reporter: Adam Kramer > > Some of the current aggregates (sum, avg) have a fairly standard behavior: If any item in the list is NULL, the sum, average, etc., cannot be computed. And so, NULL is returned. > 1) If this is the case, the query should return much faster--see a null, return NULL, exit(0). > 2) It would be nice to have versions or ways to use these functions with NULL data--specifically, to treat the NULL as zero or to ignore the NULL and return the results for non-NULL data. > This also would apply to the variance functions referenced in https://issues.apache.org/jira/browse/HIVE-165 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.