You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "James Taylor (JIRA)" <ji...@apache.org> on 2017/03/21 00:10:41 UTC

[jira] [Assigned] (PHOENIX-3746) NTH_VALUE returns 'null' when aggregating results of aggregate sub-query

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

James Taylor reassigned PHOENIX-3746:
-------------------------------------

    Assignee: Matthew Silverman

> NTH_VALUE returns 'null' when aggregating results of aggregate sub-query
> ------------------------------------------------------------------------
>
>                 Key: PHOENIX-3746
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3746
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.9.0
>            Reporter: Matthew Silverman
>            Assignee: Matthew Silverman
>             Fix For: 4.11.0
>
>         Attachments: PHOENIX-3476.patch
>
>
> {code:sql}
> CREATE TABLE IF NOT EXISTS TEST_TABLE (id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG, "DATE" INTEGER, "value" UNSIGNED_LONG);
>        
> UPSERT INTO TEST_TABLE (id, page_id, "DATE", "value") VALUES (1, 8, 0, 300);
> UPSERT INTO TEST_TABLE (id, page_id, "DATE", "value") VALUES (2, 8, 1, 7);
> UPSERT INTO TEST_TABLE (id, page_id, "DATE", "value") VALUES (3, 9, 2, 9);
> UPSERT INTO TEST_TABLE (id, page_id, "DATE", "value") VALUES (4, 9, 3, 4);
> UPSERT INTO TEST_TABLE (id, page_id, "DATE", "value") VALUES (5, 10, 4, 2);
> UPSERT INTO TEST_TABLE (id, page_id, "DATE", "value") VALUES (6, 10, 5, 150);
> SELECT NTH_VALUE(SUM_VALUE, 2) WITHIN GROUP (ORDER BY MIN_DATE DESC) FROM
>  (SELECT MIN("DATE") AS MIN_DATE, SUM("value") AS SUM_VALUE FROM TEST_TABLE GROUP BY page_id) x;
> +--------------------------------------+
> | null(MIN_DATE, false, SUM_VALUE, 2)  |
> +--------------------------------------+
> | null                                 |
> +--------------------------------------+
> {code}
> I would have expected '13' to be returned, as it is equal to 4+9.
> It appears that the {{offset}} field of the server-side aggregator is being reset on every call to {{reset()}}, when it should persist permanently on the aggregator once set.  I have attached the above example as an integration test, together with a potential fix.



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