You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Vaclav Loffelmann (JIRA)" <ji...@apache.org> on 2014/09/04 16:43:51 UTC
[jira] [Commented] (PHOENIX-1229) Coalesce on nth_value gives
ArrayIndexOutOfBoundsException
[ 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)