Julian Jaffe created PHOENIX-3348:
-------------------------------------

             Summary: SELECT DISTINCT with a non-rowkey array and an id returns 
incorrect results
                 Key: PHOENIX-3348
                 URL: https://issues.apache.org/jira/browse/PHOENIX-3348
             Project: Phoenix
          Issue Type: Bug
    Affects Versions: 4.6.0
            Reporter: Julian Jaffe


Attempting to select distinct combinations from an array and another column 
returns incorrect results if the columns are not part of the primary key.

{code:sql}
CREATE TABLE IF NOT EXISTS TEST.DESERTEST (COLONE BIGINT NOT NULL PRIMARY KEY, 
COLTWO BIGINT, COLTHREE BIGINT[]);
No rows affected (1.368 seconds)

UPSERT INTO TEST.DESERTEST VALUES (10, 7, ARRAY[1,2]);
1 row affected (0.161 seconds)

SELECT DISTINCT COLTWO, COLTHREE FROM TEST.DESERTEST WHERE COLONE = 10;
+------------------------------------------+------------------------------------------+
|                  COLTWO                  |                 COLTHREE           
      |
+------------------------------------------+------------------------------------------+
| -9223372036854677504                     | []                                 
      |
+------------------------------------------+------------------------------------------+
1 row selected (0.367 seconds)

SELECT COLTWO, COLTHREE FROM TEST.DESERTEST WHERE COLONE = 10;
+------------------------------------------+------------------------------------------+
|                  COLTWO                  |                 COLTHREE           
      |
+------------------------------------------+------------------------------------------+
| 7                                        | [1, 2]                             
      |
+------------------------------------------+------------------------------------------+
1 row selected (0.336 seconds)

SELECT DISTINCT COLONE, COLTHREE FROM TEST.DESERTEST WHERE COLONE = 10;
+------------------------------------------+------------------------------------------+
|                  COLONE                  |                 COLTHREE           
      |
+------------------------------------------+------------------------------------------+
| 10                                       | [1, 2]                             
      |
+------------------------------------------+------------------------------------------+
1 row selected (0.32 seconds)
{code}

We've confirmed this bug in 4.6, and confirmed that it does not occur in 4.8, 
although I haven't been able to locate a corresponding JIRA. However, it will 
occur if using the 4.6 client to talk to 4.8, so it appears to be at least 
partially client-side.



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

Reply via email to