Description
I'm trying to use Row Value Constructors to do paging in a query in the below table:
- TABLE #
CREATE TABLE IF NOT EXISTS COMMUNITIES.TEST (
ORGANIZATION_ID CHAR(15) NOT NULL,
SCORE DOUBLE NOT NULL,
ENTITY_ID CHAR(15) NOT NULL
CONSTRAINT TEST_PK PRIMARY KEY (
ORGANIZATION_ID,
SCORE DESC,
ENTITY_ID DESC
)
) VERSIONS=1, MULTI_TENANT=TRUE, REPLICATION_SCOPE=1, TTL=43200
UPSERT INTO COMMUNITIES.TEST VALUES ('org1',3,'01');
UPSERT INTO COMMUNITIES.TEST VALUES ('org1',2,'04');
UPSERT INTO COMMUNITIES.TEST VALUES ('org1',2,'03');
UPSERT INTO COMMUNITIES.TEST VALUES ('org1',1,'02');
- QUERY #
SELECT entity_id, score
FROM communities.test
WHERE organization_id = 'org1'
AND (score, entity_id) < (2, '04')
ORDER BY score DESC, entity_id DESC
LIMIT 3
I'm specifying the score and entity_id of the second row so I'm expecting it to return the 2 last values (with id 03 and 02). However, it returns the 3 first values (and if it wasn't for the LIMIT 3 it would just return all).