You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Nick Dimiduk (JIRA)" <ji...@apache.org> on 2016/08/23 00:19:20 UTC

[jira] [Created] (PHOENIX-3197) DATE/TIMESTAMP comparison involving rowkey column broken

Nick Dimiduk created PHOENIX-3197:
-------------------------------------

             Summary: DATE/TIMESTAMP comparison involving rowkey column broken
                 Key: PHOENIX-3197
                 URL: https://issues.apache.org/jira/browse/PHOENIX-3197
             Project: Phoenix
          Issue Type: Bug
    Affects Versions: 4.8.0, 4.7.0, 4.9.0
            Reporter: Nick Dimiduk
            Priority: Critical


Similar to PHOENIX-2944, but involving rowkey columns. This uses a different compareTo method.

The trivial test case passes:

{noformat}
drop table if exists test1;
create table test1(c1 DATE NOT NULL, constraint pk primary key(c1));

upsert into test1 values(DATE '2016-05-10 00:01:00');
upsert into test1 values(DATE '2016-05-10 00:02:00');
upsert into test1 values(DATE '2016-05-10 00:03:00');

select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test1 where c1 >= DATE '2016-05-10T00:01:02.345Z';
select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test1 where c1 >= TIMESTAMP '2016-05-10T00:01:02.345Z';
select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test1 where DATE '2016-05-10T00:01:02.345Z' < c1;
select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test1 where TIMESTAMP '2016-05-10T00:01:02.345Z' < c1;

select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test1 where c1 < DATE '2016-05-10T00:01:02.345Z';
select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test1 where c1 < TIMESTAMP '2016-05-10T00:01:02.345Z';
select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test1 where DATE '2016-05-10T00:01:02.345Z' >= c1;
select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test1 where TIMESTAMP '2016-05-10T00:01:02.345Z' >= c1;
{noformat}

But nest the date column in the rowkey and the DATE vs TIMESTAMP compares start failing:

{noformat}
drop table if exists test2;
create table test2(c1 VARCHAR NOT NULL, c2 DATE NOT NULL, c3 VARCHAR NOT NULL, constraint pk primary key(c1,c2,c3));

upsert into test2 values('a',DATE '2016-05-10 00:01:00','x');
upsert into test2 values('a',DATE '2016-05-10 00:02:00','y');
upsert into test2 values('a',DATE '2016-05-10 00:03:00','z');

select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test2 where c2 >= DATE '2016-05-10T00:01:02.345Z';
select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test2 where c2 >= TIMESTAMP '2016-05-10T00:01:02.345Z';
select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test2 where DATE '2016-05-10T00:01:02.345Z' < c2;
select case count(1) when 2 then 'PASS' else 'FAIL' end as test from test2 where TIMESTAMP '2016-05-10T00:01:02.345Z' < c2;

select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test2 where c2 < DATE '2016-05-10T00:01:02.345Z';
select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test2 where c2 < TIMESTAMP '2016-05-10T00:01:02.345Z';
select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test2 where DATE '2016-05-10T00:01:02.345Z' >= c2;
select case count(1) when 1 then 'PASS' else 'FAIL' end as test from test2 where TIMESTAMP '2016-05-10T00:01:02.345Z' >= c2;
{noformat}



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