Return-Path: X-Original-To: apmail-drill-issues-archive@minotaur.apache.org Delivered-To: apmail-drill-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B7AE7C3EF for ; Fri, 19 Dec 2014 02:38:13 +0000 (UTC) Received: (qmail 49514 invoked by uid 500); 19 Dec 2014 02:38:13 -0000 Delivered-To: apmail-drill-issues-archive@drill.apache.org Received: (qmail 49481 invoked by uid 500); 19 Dec 2014 02:38:13 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 49471 invoked by uid 99); 19 Dec 2014 02:38:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Dec 2014 02:38:13 +0000 Date: Fri, 19 Dec 2014 02:38:13 +0000 (UTC) From: "Aman Sinha (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (DRILL-1897) Using 'avg' along with 'length' results in wrong output when nulls are present MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DRILL-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Aman Sinha reassigned DRILL-1897: --------------------------------- Assignee: Aman Sinha > Using 'avg' along with 'length' results in wrong output when nulls are present > ------------------------------------------------------------------------------ > > Key: DRILL-1897 > URL: https://issues.apache.org/jira/browse/DRILL-1897 > Project: Apache Drill > Issue Type: Bug > Components: Functions - Drill > Reporter: Rahul Challapalli > Assignee: Aman Sinha > > git.commit.id.abbrev=9dfa4a1 > Dataset : > {code} > { > "col1":1, > "col2":"abc" > } > { > "col1":1, > "col2":null > } > { > "col1":null, > "col2":null > } > {code} > The below query should return 3 instead of 1 (postgres correctly returns 3). > Query : > {code} > select avg(length(col2)) from `a.json`; > +------------+ > | EXPR$0 | > +------------+ > | 1.0 | > +------------+ > {code} > Plan for the above query : > {code} > 00-00 Screen > 00-01 Project(EXPR$0=[CAST(/(CastHigh(CASE(=($1, 0), null, $0)), $1)):ANY]) > 00-02 StreamAgg(group=[{}], agg#0=[$SUM0($0)], agg#1=[COUNT()]) > 00-03 Project($f0=[length($0)]) > 00-04 Scan(groupscan=[EasyGroupScan [selectionRoot=/drill/testdata/data-shapes/wide-columns/flat/json/a.json, numFiles=1, columns=[`col2`], files=[maprfs:/drill/testdata/data-shapes/wide-columns/flat/json/a.json]]]) > {code} > The below query which does not involve a second function works as expected even though nulls are present > {code} > select avg(col1) from `a.json`; > +------------+ > | EXPR$0 | > +------------+ > | 1.0 | > +------------+ > {code} > Let me know if you need any more information. -- This message was sent by Atlassian JIRA (v6.3.4#6332)