From dev-return-48820-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Fri Jan 26 04:33:07 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id ECD3B180676 for ; Fri, 26 Jan 2018 04:33:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D7D49160C3D; Fri, 26 Jan 2018 03:33:06 +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 2EFC8160C4F for ; Fri, 26 Jan 2018 04:33:06 +0100 (CET) Received: (qmail 48008 invoked by uid 500); 26 Jan 2018 03:33:03 -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 47986 invoked by uid 99); 26 Jan 2018 03:33:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jan 2018 03:33:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id E0952C212E for ; Fri, 26 Jan 2018 03:33:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id JfpV067aXsQS for ; Fri, 26 Jan 2018 03:33:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id BD5E35F3BA for ; Fri, 26 Jan 2018 03:33:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id F3581E0F41 for ; Fri, 26 Jan 2018 03:33:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 15E4D240F2 for ; Fri, 26 Jan 2018 03:33:00 +0000 (UTC) Date: Fri, 26 Jan 2018 03:33:00 +0000 (UTC) From: "James Taylor (JIRA)" To: dev@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PHOENIX-4560) ORDER BY with GROUP BY doesn't work if there is WHERE on pk column MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PHOENIX-4560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16340518#comment-16340518 ] James Taylor commented on PHOENIX-4560: --------------------------------------- No problem, [~sergey.soldatov]. You did the hard part by isolating the issue. I attached a final patch that includes your end-to-end test as well. > ORDER BY with GROUP BY doesn't work if there is WHERE on pk column > ------------------------------------------------------------------ > > Key: PHOENIX-4560 > URL: https://issues.apache.org/jira/browse/PHOENIX-4560 > Project: Phoenix > Issue Type: Bug > Affects Versions: 4.14.0 > Reporter: Sergey Soldatov > Assignee: James Taylor > Priority: Major > Fix For: 4.14.0 > > Attachments: PHOENIX-4560_v1.patch, PHOENIX-4560_v2.patch > > > It's related to the optimizations for group by that were made in PHOENIX-3451. Test case to reproduce: > {noformat} > CREATE TABLE IF NOT EXISTS VA_TEST(ID VARCHAR NOT NULL PRIMARY KEY, VAL1 VARCHAR, VAL2 INTEGER); > UPSERT INTO VA_TEST VALUES('ABC','aa123', 11); > UPSERT INTO VA_TEST VALUES('ABD','ba124', 1); > UPSERT INTO VA_TEST VALUES('ABE','cf125', 13); > UPSERT INTO VA_TEST VALUES('ABF','dan126', 4); > UPSERT INTO VA_TEST VALUES('ABG','elf127', 15); > UPSERT INTO VA_TEST VALUES('ABH','fan128', 6); > UPSERT INTO VA_TEST VALUES('AAA','get211', 100); > UPSERT INTO VA_TEST VALUES('AAB','hat212', 7); > UPSERT INTO VA_TEST VALUES('AAC','aap12', 2); > UPSERT INTO VA_TEST VALUES('AAD','ball12', 3); > UPSERT INTO VA_TEST VALUES('AAE','inn2110', 13); > UPSERT INTO VA_TEST VALUES('AAF','key2112', 40); > select distinct ID, VAL1, VAL2 from VA_TEST where "ID" in ('ABC','ABD','ABE','ABF','ABG','ABH','AAA', 'AAB', 'AAC','AAD','AAE','AAF') order by VAL1 ASC; > {noformat} > Execution result : > {noformat} > +------+----------+-------+ > | ID | VAL1 | VAL2 | > +------+----------+-------+ > | AAA | get211 | 100 | > | AAB | hat212 | 7 | > | AAC | aap12 | 2 | > | AAD | ball12 | 3 | > | AAE | inn2110 | 13 | > | AAF | key2112 | 40 | > | ABC | aa123 | 11 | > | ABD | ba124 | 1 | > | ABE | cf125 | 13 | > | ABF | dan126 | 4 | > | ABG | elf127 | 15 | > | ABH | fan128 | 6 | > +------+----------+-------+ > {noformat} > Explain plan: > {noformat} > +----------------------------------------------------------------------------------------+-----------------+----------------+----------------+ > | PLAN | EST_BYTES_READ | EST_ROWS_READ | EST_INFO_TS | > +----------------------------------------------------------------------------------------+-----------------+----------------+----------------+ > | CLIENT 1-CHUNK 12 ROWS 1908 BYTES PARALLEL 1-WAY POINT LOOKUP ON 12 KEYS OVER VA_TEST | 1908 | 12 | 1516917709099 | > | SERVER AGGREGATE INTO DISTINCT ROWS BY ["ID", "VAL1", "VAL2"] | 1908 | 12 | 1516917709099 | > | CLIENT MERGE SORT | 1908 | 12 | 1516917709099 | > +----------------------------------------------------------------------------------------+-----------------+----------------+----------------+ > {noformat} > As we can see there is no client side sort, so it keeps the original order we get from server which is wrong. > That happens because of OrderPreservingTracker.hasEqualityConstraints decides that WHERE clause on ID column is constant and let us perform the optimization and skip the client side sort. > [~jamestaylor], [~chenglei] any thoughts? -- This message was sent by Atlassian JIRA (v7.6.3#76005)