phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vaclav Loffelmann (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-1229) Coalesce on nth_value gives ArrayIndexOutOfBoundsException
Date Thu, 04 Sep 2014 14:43:51 GMT

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

Vaclav Loffelmann commented on PHOENIX-1229:
--------------------------------------------

[~jmahonin] Thanks for report. However this is not bug of NTH_VALUE but in COALESCE function.
I've created [PHOENIX 1237|https://issues.apache.org/jira/browse/PHOENIX-1237] for that.

> Coalesce on nth_value gives ArrayIndexOutOfBoundsException
> ----------------------------------------------------------
>
>                 Key: PHOENIX-1229
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1229
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 5.0.0
>            Reporter: Josh Mahonin
>            Assignee: Vaclav Loffelmann
>
> Running a query with "NTH_VALUE" can result in null values returning, which is expected.
When wrapping the results in a coalesce, a java.lang.ArrayIndexOutOfBoundsException is thrown.
> Reproducible test case below:
> {code}
> -- Create table
> CREATE TABLE TEST_NTH(
>     ID BIGINT NOT NULL, 
>     DATE TIMESTAMP NOT NULL, 
>     COUNT BIGINT 
>     CONSTRAINT pk PRIMARY KEY(ID, DATE));
> -- Sample values
> UPSERT INTO TEST_NTH(ID, DATE, COUNT) VALUES(1, CURRENT_TIME(), 1);
> UPSERT INTO TEST_NTH(ID, DATE, COUNT) VALUES(1, CURRENT_TIME(), 2);
> UPSERT INTO TEST_NTH(ID, DATE, COUNT) VALUES(2, CURRENT_TIME(), 1);
> -- Select nth, returns null for id 2, OK
> SELECT ID, 
>        NTH_VALUE(COUNT, 2) 
>        WITHIN GROUP (ORDER BY COUNT DESC) 
> FROM TEST_NTH 
> GROUP BY ID;
> -- Using coalesce throws java.lang.ArrayIndexOutOfBoundsException
> SELECT ID,
>        COALESCE(
>             NTH_VALUE(COUNT, 2)
>             WITHIN GROUP (ORDER BY COUNT DESC),
>        0)
> FROM TEST_NTH
> GROUP BY id;
> {code}



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

Mime
View raw message