[ 
https://issues.apache.org/jira/browse/DRILL-1475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14154333#comment-14154333
 ] 

B Anil Kumar commented on DRILL-1475:
-------------------------------------

Hi Neeraja,

I have verified this, aggregations are working fine. I think you tested with 
"store.mongo.all_text_mode = true". Can you please check?

{noformat}
BANL122d28a3e:drillRelease abatchu$ bin/sqlline -u jdbc:drill:zk=localhost:2181 
 -n admin -p admin
sqlline version 1.1.6
0: jdbc:drill:zk=localhost:2181> select state,sum(pop) from mongo.test.`zips` 
zipcodes group by state having sum(pop) > 10000000 order by sum(pop) desc limit 
10
. . . . . . . . . . . . . . . .> ;
+------------+------------+
|   state    |   EXPR$1   |
+------------+------------+
+------------+------------+
No rows selected (1.214 seconds)
0: jdbc:drill:zk=localhost:2181> select state,sum(pop) from mongo.test.`zips` 
zipcodes group by state having sum(pop) > 10000000 order by sum(pop) desc;
+------------+------------+
|   state    |   EXPR$1   |
+------------+------------+
| CA         | 29754890   |
| NY         | 17990402   |
| TX         | 16984601   |
| FL         | 12686644   |
| PA         | 11881643   |
| IL         | 11427576   |
| OH         | 10846517   |
+------------+------------+
7 rows selected (0.751 seconds)
0: jdbc:drill:zk=localhost:2181> select state,city,avg(pop) from 
mongo.test.`zips` zipcodes group by state, city limit 5;
+------------+------------+------------+
|   state    |    city    |   EXPR$2   |
+------------+------------+------------+
| MA         | AGAWAM     | 15338.0    |
| MA         | CUSHMAN    | 36963.0    |
| MA         | BARRE      | 4546.0     |
| MA         | BELCHERTOWN | 10579.0    |
| MA         | BLANDFORD  | 1240.0     |
+------------+------------+------------+
5 rows selected (0.985 seconds)
0: jdbc:drill:zk=localhost:2181> select city, sum(pop) from mongo.test.`zips` 
zipcodes where state is not null group by city order by sum(pop) desc limit 1;
+------------+------------+
|    city    |   EXPR$1   |
+------------+------------+
| CHICAGO    | 2452177    |
+------------+------------+
1 row selected (1.072 seconds)
0: jdbc:drill:zk=localhost:2181> select city, sum(pop) from mongo.test.`zips` 
zipcodes where state is not null group by city order by sum(pop) asc limit 1;
+------------+------------+
|    city    |   EXPR$1   |
+------------+------------+
| BUSTINS ISLAND | 0          |
+------------+------------+
1 row selected (0.979 seconds)
{noformat}

When I enable "store.mongo.all_text_mode = true", then it will fail. This is 
expected as discussed in https://issues.apache.org/jira/browse/DRILL-1460

{noformat}

: jdbc:drill:zk=localhost:2181> alter system set `store.mongo.all_text_mode` = 
true;
+------------+------------+
|     ok     |  summary   |
+------------+------------+
| true       | store.mongo.all_text_mode updated. |
+------------+------------+
1 row selected (0.052 seconds)
0: jdbc:drill:zk=localhost:2181> select state,sum(pop) from mongo.test.`zips` 
zipcodes group by state having sum(pop) > 10000000 order by sum(pop) desc;
Query failed: Failure while running fragment. Invalid value for boolean: 15338 
[a5788880-a28a-432d-a434-b1ff1c960891]

Error: exception while executing query: Failure while trying to get next result 
batch. (state=,code=0)
0: jdbc:drill:zk=localhost:2181>

{noformat}

> MongoDB storage plugin errors with sum/avg functions
> ----------------------------------------------------
>
>                 Key: DRILL-1475
>                 URL: https://issues.apache.org/jira/browse/DRILL-1475
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 0.6.0
>            Reporter: Neeraja
>
> Using the latest code from Apache Drill 0.6 branch and hitting issues with 
> the mongodb plugin.
> Dataset is used is the mongo DB zips dataset.
> 0: jdbc:drill:zk=local> select state, sum(pop) from zips group by state order 
> by state;
> Query failed: Failure while running fragment. Invalid value for boolean: 
> 15338 [8b6073af-a6ba-4516-ad9b-144f486c548c]
> Error: exception while executing query: Failure while trying to get next 
> result batch. (state=,code=0)
> 0: jdbc:drill:zk=local> select state, avg(pop) from zips group by state order 
> by state;
> Query failed: Failure while running fragment. Invalid value for boolean: 
> 15338 [79d074a9-6299-4e8c-8ca4-aedef3873c49]
> Error: exception while executing query: Failure while trying to get next 
> result batch. (state=,code=0)
> -------
> Explain plan output.
> 0: jdbc:drill:zk=local> explain plan for select state, avg(pop) from zips 
> group by state order by state;
> +------------+------------+
> |    text    |    json    |
> +------------+------------+
> | 00-00    Screen
> 00-01      Project(state=[$0], EXPR$1=[$1])
> 00-02        SelectionVectorRemover
> 00-03          Sort(sort0=[$0], dir0=[ASC])
> 00-04            Project(state=[$0], EXPR$1=[CAST(/(CastHigh(CASE(=($2, 0), 
> null, $1)), $2)):ANY])
> 00-05              HashAgg(group=[{0}], agg#0=[$SUM0($1)], agg#1=[COUNT($1)])
> 00-06                Project(state=[$1], pop=[$0])
> 00-07                  Scan(groupscan=[MongoGroupScan 
> [MongoScanSpec=MongoScanSpec [dbName=newzipdb, collectionName=zips, 
> filters=null], columns=[SchemaPath [`state`], SchemaPath [`pop`]]]])
>  | {
>   "head" : {
>     "version" : 1,
>     "generator" : {
>       "type" : "ExplainHandler",
>       "info" : ""
>     },
>     "type" : "APACHE_DRILL_PHYSICAL",
>     "options" : [ ],
>     "queue" : 0,
>     "resultMode" : "EXEC"
>   },
>   "graph" : [ {
>     "pop" : "mongo-scan",
>     "@id" : 7,
>     "mongoScanSpec" : {
>       "dbName" : "newzipdb",
>       "collectionName" : "zips",
>       "filters" : null
>     },
>     "storage" : {
>       "type" : "mongo",
>       "connection" : "mongodb://localhost:27017",
>       "enabled" : true
>     },
>     "columns" : [ "`state`", "`pop`" ],
>     "cost" : 29353.0
>   }, {
>     "pop" : "project",
>     "@id" : 6,
>     "exprs" : [ {
>       "ref" : "`state`",
>       "expr" : "`state`"
>     }, {
>       "ref" : "`pop`",
>       "expr" : "`pop`"
>     } ],
>     "child" : 7,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000,
>     "cost" : 29353.0
>   }, {
>     "pop" : "hash-aggregate",
>     "@id" : 5,
>     "child" : 6,
>     "cardinality" : 1.0,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000,
>     "cost" : 14676.5,
>     "groupByExprs" : [ {
>       "ref" : "`state`",
>       "expr" : "`state`"
>     } ],
>     "aggrExprs" : [ {
>       "ref" : "`$f1`",
>       "expr" : "$sum0(`pop`) "
>     }, {
>       "ref" : "`$f2`",
>       "expr" : "count(`pop`) "
>     } ]
>   }, {
>     "pop" : "project",
>     "@id" : 4,
>     "exprs" : [ {
>       "ref" : "`state`",
>       "expr" : "`state`"
>     }, {
>       "ref" : "`EXPR$1`",
>       "expr" : "divide(casthigh( ( if (equal(`$f2`, 0)  ) then (NULL )  else 
> (`$f1` )  end  ) ) , `$f2`) "
>     } ],
>     "child" : 5,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000,
>     "cost" : 2935.3
>   }, {
>     "pop" : "external-sort",
>     "@id" : 3,
>     "child" : 4,
>     "orderings" : [ {
>       "order" : "ASC",
>       "expr" : "`state`",
>       "nullDirection" : "UNSPECIFIED"
>     } ],
>     "reverse" : false,
>     "initialAllocation" : 20000000,
>     "maxAllocation" : 10000000000,
>     "cost" : 2935.3
>   }, {
>     "pop" : "selection-vector-remover",
>     "@id" : 2,
>     "child" : 3,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000,
>     "cost" : 2935.3
>   }, {
>     "pop" : "project",
>     "@id" : 1,
>     "exprs" : [ {
>       "ref" : "`state`",
>       "expr" : "`state`"
>     }, {
>       "ref" : "`EXPR$1`",
>       "expr" : "`EXPR$1`"
>     } ],
>     "child" : 2,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000,
>     "cost" : 2935.3
>   }, {
>     "pop" : "screen",
>     "@id" : 0,
>     "child" : 1,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000,
>     "cost" : 2935.3
>   } ]
> } |
> +------------+------------+



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to