You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Yingyi Bu (JIRA)" <ji...@apache.org> on 2017/05/03 05:11:05 UTC

[jira] [Closed] (ASTERIXDB-1897) NPE in complex group-by query

     [ https://issues.apache.org/jira/browse/ASTERIXDB-1897?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Yingyi Bu closed ASTERIXDB-1897.
--------------------------------
    Resolution: Fixed

> NPE in complex group-by query
> -----------------------------
>
>                 Key: ASTERIXDB-1897
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1897
>             Project: Apache AsterixDB
>          Issue Type: Bug
>            Reporter: Yingyi Bu
>            Assignee: Yingyi Bu
>
> The DDLs and query are as follows:
> {noformat}
> DROP DATAVERSE gby IF EXISTS;
> CREATE DATAVERSE gby;
> USE gby;
> CREATE TYPE PolicyType AS {
>     id: UUID
> }
> CREATE DATASET policies(PolicyType) PRIMARY KEY id AUTOGENERATED;
> INSERT INTO policies
> (
>   [ {
>     "policyno": "C123",
>     "state": "CA",
>     "zipcode": "96008",
>     "make": "Honda",
>     "accidents": [
>           {
>             "year": "2015",
>             "cost": 5000
>           },
>           {
>             "year": "2016",
>             "cost": 8000
>           },
>           {
>             "year": "2016",
>             "cost": 6000
>           }
>     ]
>   },
>   {
>     "policyno": "C124",
>     "state": "CA",
>     "zipcode": "96853",
>     "make": "Ford",
>     "accidents": [
>           {
>             "year": "2015",
>             "cost": 5000
>           },
>           {
>             "year": "2015",
>             "cost": 8000
>           },
>           {
>             "year": "2016",
>             "cost": 6000
>           }
>     ]
>   },
>   {
>     "policyno": "A123",
>     "state": "AZ",
>     "zipcode": "86008",
>     "make": "Honda",
>     "accidents": [
>         {
>           "year": "2015",
>           "cost": 5000
>         },
>         {
>           "year": "2016",
>           "cost": 8000
>         },
>         {
>           "year": "2016",
>           "cost": 6000
>         }
>     ]
>   },
>   {
>     "policyno": "A124",
>     "state": "AZ",
>     "zipcode": "86853",
>     "make": "Ford",
>     "accidents": [
>         {
>           "year": "2015",
>           "cost": 5000
>         },
>         {
>           "year": "2016",
>           "cost": 8000
>         },
>         {
>           "year": "2016",
>           "cost": 6000
>         }
>     ]
>   },
>   {
>     "policyno": "U123",
>     "state": "UT",
>     "zipcode": "66008",
>     "make": "Honda",
>     "accidents": [
>         {
>           "year": "2015",
>           "cost": 5000
>         },
>         {
>           "year": "2016",
>           "cost": 8000
>         },
>         {
>           "year": "2016",
>           "cost": 6000
>         }
>     ]
>   },
>   {
>     "policyno": "U124",
>     "state": "UT",
>     "zipcode": "66853",
>     "make": "Ford",
>     "accidents": [ ]
>   },
>   {
>     "policyno": "U125",
>     "state": "UT",
>     "zipcode": "66853",
>     "make": "Ford"
>   } ]
> );
> FROM policies p
> GROUP BY state GROUP AS g
> SELECT state,
>        (
>          FROM g
>          SELECT VALUE SUM(
>                   (
>                     FROM g.p.accidents a
>                     WHERE a.year = "2016"
>                     SELECT VALUE COUNT(*)
>                    )[0]
>                 )
>        )[0]  / (COUNT(*) * 1.0 ) AS risk
> ORDER BY risk DESC
> LIMIT 5;
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)