Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6C80F200BB7 for ; Wed, 9 Nov 2016 16:02:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6B530160AF7; Wed, 9 Nov 2016 15:02:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BC513160AFD for ; Wed, 9 Nov 2016 16:01:59 +0100 (CET) Received: (qmail 69336 invoked by uid 500); 9 Nov 2016 15:01:58 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 69021 invoked by uid 99); 9 Nov 2016 15:01:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2016 15:01:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 750EE2C2A66 for ; Wed, 9 Nov 2016 15:01:58 +0000 (UTC) Date: Wed, 9 Nov 2016 15:01:58 +0000 (UTC) From: "James Taylor (JIRA)" To: dev@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PHOENIX-3452) Secondary index and query using distinct: ORDER BY doesn't work correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 09 Nov 2016 15:02:00 -0000 [ https://issues.apache.org/jira/browse/PHOENIX-3452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15651169#comment-15651169 ] James Taylor commented on PHOENIX-3452: --------------------------------------- Yes, that's correct. > Secondary index and query using distinct: ORDER 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 > Assignee: chenglei > Attachments: PHOENIX-3452_v2.patch > > > 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)