drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Altekruse (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (DRILL-1607) Unable to use Flatten with sum/avg aggregate functions
Date Sun, 09 Nov 2014 20:33:33 GMT

     [ 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)

Mime
View raw message