You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Joel Palmert (JIRA)" <ji...@apache.org> on 2016/11/04 14:25:58 UTC

[jira] [Updated] (PHOENIX-3452) Secondary index and query using distinct: ORDE BY doesn't work correctly

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

Joel Palmert updated PHOENIX-3452:
----------------------------------
    Description: 
This may be related to PHOENIX-3451 but the behavior is different so filing it separately.

Steps to repro:
CREATE TABLE IF NOT EXISTS TEST.TEST (
    ORGANIZATION_ID CHAR(15) NOT NULL,
    CONTAINER_ID CHAR(15) NOT NULL,
    ENTITY_ID CHAR(15) NOT NULL,
    SCORE DOUBLE,
    CONSTRAINT TEST_PK PRIMARY KEY (
        ORGANIZATION_ID,
        CONTAINER_ID,
        ENTITY_ID
    )
) VERSIONS=1, MULTI_TENANT=TRUE, REPLICATION_SCOPE=1, TTL=31536000;
CREATE INDEX IF NOT EXISTS TEST_SCORE ON TEST.TEST (CONTAINER_ID, SCORE DESC, ENTITY_ID DESC);

UPSERT INTO test.test VALUES ('org1','container1','entityId6',1.1);
UPSERT INTO test.test VALUES ('org1','container1','entityId5',1.2);
UPSERT INTO test.test VALUES ('org1','container1','entityId4',1.3);
UPSERT INTO test.test VALUES ('org1','container1','entityId3',1.4);
UPSERT INTO test.test VALUES ('org1','container1','entityId2',1.5);
UPSERT INTO test.test VALUES ('org1','container1','entityId1',1.6);

SELECT DISTINCT entity_id, score
FROM test.test
WHERE organization_id = 'org1'
AND container_id = 'container1'
ORDER BY score DESC

Notice that the returned results are not returned in descending score order. Instead they are returned in descending entity_id order. If I remove the DISTINCT or remove the secondary index the result is correct.

  was:
This may be related to PHOENIX-3451 but the behavior is different so filing it separately.

Steps to repro:
DROP TABLE TEST.TEST;
CREATE TABLE IF NOT EXISTS TEST.TEST (
    ORGANIZATION_ID CHAR(15) NOT NULL,
    CONTAINER_ID CHAR(15) NOT NULL,
    ENTITY_ID CHAR(15) NOT NULL,
    SCORE DOUBLE,
    CONSTRAINT TEST_PK PRIMARY KEY (
        ORGANIZATION_ID,
        CONTAINER_ID,
        ENTITY_ID
    )
) VERSIONS=1, MULTI_TENANT=TRUE, REPLICATION_SCOPE=1, TTL=31536000;
CREATE INDEX IF NOT EXISTS TEST_SCORE ON TEST.TEST (CONTAINER_ID, SCORE DESC, ENTITY_ID DESC);

UPSERT INTO test.test VALUES ('org1','container1','entityId6',1.1);
UPSERT INTO test.test VALUES ('org1','container1','entityId5',1.2);
UPSERT INTO test.test VALUES ('org1','container1','entityId4',1.3);
UPSERT INTO test.test VALUES ('org1','container1','entityId3',1.4);
UPSERT INTO test.test VALUES ('org1','container1','entityId2',1.5);
UPSERT INTO test.test VALUES ('org1','container1','entityId1',1.6);

SELECT DISTINCT entity_id, score
FROM test.test
WHERE organization_id = 'org1'
AND container_id = 'container1'
ORDER BY score DESC

Notice that the returned results are not returned in descending score order. Instead they are returned in descending entity_id order. If I remove the DISTINCT or remove the secondary index the result is correct.


> Secondary index and query using distinct: ORDE BY doesn't work correctly
> ------------------------------------------------------------------------
>
>                 Key: PHOENIX-3452
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3452
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.8.0
>            Reporter: Joel Palmert
>
> This may be related to PHOENIX-3451 but the behavior is different so filing it separately.
> Steps to repro:
> CREATE TABLE IF NOT EXISTS TEST.TEST (
>     ORGANIZATION_ID CHAR(15) NOT NULL,
>     CONTAINER_ID CHAR(15) NOT NULL,
>     ENTITY_ID CHAR(15) NOT NULL,
>     SCORE DOUBLE,
>     CONSTRAINT TEST_PK PRIMARY KEY (
>         ORGANIZATION_ID,
>         CONTAINER_ID,
>         ENTITY_ID
>     )
> ) VERSIONS=1, MULTI_TENANT=TRUE, REPLICATION_SCOPE=1, TTL=31536000;
> CREATE INDEX IF NOT EXISTS TEST_SCORE ON TEST.TEST (CONTAINER_ID, SCORE DESC, ENTITY_ID DESC);
> UPSERT INTO test.test VALUES ('org1','container1','entityId6',1.1);
> UPSERT INTO test.test VALUES ('org1','container1','entityId5',1.2);
> UPSERT INTO test.test VALUES ('org1','container1','entityId4',1.3);
> UPSERT INTO test.test VALUES ('org1','container1','entityId3',1.4);
> UPSERT INTO test.test VALUES ('org1','container1','entityId2',1.5);
> UPSERT INTO test.test VALUES ('org1','container1','entityId1',1.6);
> SELECT DISTINCT entity_id, score
> FROM test.test
> WHERE organization_id = 'org1'
> AND container_id = 'container1'
> ORDER BY score DESC
> Notice that the returned results are not returned in descending score order. Instead they are returned in descending entity_id order. If I remove the DISTINCT or remove the secondary index the result is correct.



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