phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Josh Mahonin (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (PHOENIX-1229) Coalesce on nth_value gives ArrayIndexOutOfBoundsException
Date Tue, 02 Sep 2014 15:59:20 GMT

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

Josh Mahonin updated PHOENIX-1229:
----------------------------------
    Description: 
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}

  was:
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:

-- 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;


> 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
>
> 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