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 B1604172F2 for ; Sun, 9 Nov 2014 20:34:00 +0000 (UTC) Received: (qmail 90281 invoked by uid 500); 9 Nov 2014 20:33:58 -0000 Delivered-To: apmail-drill-issues-archive@drill.apache.org Received: (qmail 90252 invoked by uid 500); 9 Nov 2014 20:33:58 -0000 Mailing-List: contact issues-help@drill.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.incubator.apache.org Delivered-To: mailing list issues@drill.incubator.apache.org Received: (qmail 90243 invoked by uid 99); 9 Nov 2014 20:33:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Nov 2014 20:33:58 +0000 X-ASF-Spam-Status: No, hits=-2000.6 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 09 Nov 2014 20:33:36 +0000 Received: (qmail 90197 invoked by uid 99); 9 Nov 2014 20:33:33 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Nov 2014 20:33:33 +0000 Date: Sun, 9 Nov 2014 20:33:33 +0000 (UTC) From: "Jason Altekruse (JIRA)" To: issues@drill.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (DRILL-1607) Unable to use Flatten with sum/avg aggregate functions 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/DRILL-1607?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jason Altekruse resolved DRILL-1607. ------------------------------------ Resolution: Duplicate > Unable to use Flatten with sum/avg aggregate functions > ------------------------------------------------------ > > Key: DRILL-1607 > URL: https://issues.apache.org/jira/browse/DRILL-1607 > Project: Apache Drill > Issue Type: Bug > Reporter: Neeraja > Assignee: Jason Altekruse > > Unable to use flatten with arithmetic aggregations such as sum, avg. count, min, max and plain listing of fields work. > 0: jdbc:drill:zk=local> select c.f.name, c.f.gender,c.f.age from > . . . . . . . . . . . > (select flatten(children) as f from dfs.`/Users/nrentachintala/Downloads/drillreleases/apache-drill-0.7.0-incubating-SNAPSHOT/sample-data/test.json`) c; > +------------+------------+------------+ > | EXPR$0 | EXPR$1 | EXPR$2 | > +------------+------------+------------+ > | Jane | Female | 6 | > | John | Male | 15 | > | Earl | Male | 10 | > | Sam | Male | 6 | > | Kit | Male | 8 | > +------------+------------+------------+ > 5 rows selected (0.271 seconds) > 0: jdbc:drill:zk=local> > 0: jdbc:drill:zk=local> select count(*) from > . . . . . . . . . . . > (select flatten(children) as f from dfs.`/Users/nrentachintala/Downloads/drillreleases/apache-drill-0.7.0-incubating-SNAPSHOT/sample-data/test.json`) c; > +------------+ > | EXPR$0 | > +------------+ > | 5 | > +------------+ > 1 row selected (0.219 seconds) > 0: jdbc:drill:zk=local> > 0: jdbc:drill:zk=local> > 0: jdbc:drill:zk=local> select avg(c.f.age) from > . . . . . . . . . . . > (select flatten(children) as f from dfs.`/Users/nrentachintala/Downloads/drillreleases/apache-drill-0.7.0-incubating-SNAPSHOT/sample-data/test.json`) c > . . . . . . . . . . . > ; > +------------+ > | EXPR$0 | > +------------+ > Query failed: Failure while running fragment. > java.lang.RuntimeException: java.sql.SQLException: Failure while executing query. > at sqlline.SqlLine$IncrementalRows.hasNext(SqlLine.java:2514) > at sqlline.SqlLine$TableOutputFormat.print(SqlLine.java:2148) > at sqlline.SqlLine.print(SqlLine.java:1809) > at sqlline.SqlLine$Commands.execute(SqlLine.java:3766) > at sqlline.SqlLine$Commands.sql(SqlLine.java:3663) > at sqlline.SqlLine.dispatch(SqlLine.java:889) > at sqlline.SqlLine.begin(SqlLine.java:763) > at sqlline.SqlLine.start(SqlLine.java:498) > at sqlline.SqlLine.main(SqlLine.java:460) > JSON file used is below: > {"kind": "person", "fullName": "John Doe", "age": 22, "gender": "Male", "phoneNumber": { "areaCode": "206", "number": "1234567"}, "children": [{ "name": "Jane", "gender": "Female", "age": "6"}, {"name": "John", "gender": "Male", "age": "15"}], "citiesLived": [{ "place": "Seattle", "yearsLived": ["1995"]}, {"place": "Stockholm", "yearsLived": ["2005"]}]} > {"kind": "person", "fullName": "Mike Jones", "age": 35, "gender": "Male", "phoneNumber": { "areaCode": "622", "number": "1567845"}, "children": [{ "name": "Earl", "gender": "Male", "age": "10"}, {"name": "Sam", "gender": "Male", "age": "6"}, { "name": "Kit", "gender": "Male", "age": "8"}], "citiesLived": [{"place": "Los Angeles", "yearsLived": ["1989", "1993", "1998", "2002"]}, {"place": "Washington DC", "yearsLived": ["1990", "1993", "1998", "2008"]}, {"place": "Portland", "yearsLived": ["1993", "1998", "2003", "2005"]}, {"place": "Austin", "yearsLived": ["1973", "1998", "2001", "2005"]}]} > {"kind": "person", "fullName": "Anna Karenina", "age": 45, "gender": "Female", "phoneNumber": { "areaCode": "425", "number": "1984783"}, "citiesLived": [{"place": "Stockholm", "yearsLived": ["1992", "1998", "2000", "2010"]}, {"place": "Russia", "yearsLived": ["1998", "2001", "2005"]}, {"place": "Austin", "yearsLived": ["1995", "1999"]}]} > Explain plan for the avg query is below. > 0: jdbc:drill:zk=local> explain plan for select avg(c.f.age) from > . . . . . . . . . . . > (select flatten(children) as f from dfs.`/Users/nrentachintala/Downloads/drillreleases/apache-drill-0.7.0-incubating-SNAPSHOT/sample-data/test.json`) c > . . . . . . . . . . . > ; > +------------+------------+ > | text | json | > +------------+------------+ > | 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 | > +------------+------------+ -- This message was sent by Atlassian JIRA (v6.3.4#6332)