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 B4E63200D68 for ; Thu, 28 Dec 2017 11:17:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B35DB160C16; Thu, 28 Dec 2017 10:17:05 +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 0D352160C1F for ; Thu, 28 Dec 2017 11:17:04 +0100 (CET) Received: (qmail 28507 invoked by uid 500); 28 Dec 2017 10:17:04 -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 28496 invoked by uid 99); 28 Dec 2017 10:17:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Dec 2017 10:17:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 96D7A1A0317 for ; Thu, 28 Dec 2017 10:17:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Xn3tFEwdOLqz for ; Thu, 28 Dec 2017 10:17: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 127215F39D for ; Thu, 28 Dec 2017 10:17:02 +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 4C6CEE258A for ; Thu, 28 Dec 2017 10:17:01 +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 74F542410C for ; Thu, 28 Dec 2017 10:17:00 +0000 (UTC) Date: Thu, 28 Dec 2017 10:17:00 +0000 (UTC) From: "Sokolov Yura (JIRA)" To: dev@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (PHOENIX-4506) Subquery IN demands column from order statement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 28 Dec 2017 10:17:05 -0000 Sokolov Yura created PHOENIX-4506: ------------------------------------- Summary: Subquery IN demands column from order statement Key: PHOENIX-4506 URL: https://issues.apache.org/jira/browse/PHOENIX-4506 Project: Phoenix Issue Type: Bug Environment: awm emr phoenix 4.11.0 hbase 1.3 Reporter: Sokolov Yura I have a table: {code} create immutable table product_history_v3 ( ts bigint not null, id varchar not null, product varchar, merchantid varchar, storeid varchar, constraint pk primary key (ts, id) ) compression=LZ4,max_filesize=150000000,memstore_flushsize=70000000, versions=1,update_cache_frequency=1000,append_only_schema=true, guid_posts_width=10000000, SALT_BUCKETS=20; create local index product_history_v3_id_ts on product_history_v3 (id, ts) compression=LZ4; create local index product_history_v3_merchantid_ts on product_history_v3 (merchantid, ts) include (id) compression=LZ4; create local index product_history_v3_storeid_ts on product_history_v3 (storeid, ts) include (id) compression=LZ4; {code} Phoneix forbids following query: {code} 0: jdbc:phoenix:localhost:2181:/hbase> explain select id, ts, substr(product, 1, 20) from product_history_v3 where (id, ts) in (select id, ts from product_history_v3 where merchantid = '1479114284851799852-2-11-118-1577502676' and ts > 1514425550000 order by storeid, id, ts limit 500) order by storeid, id, ts; Error: ERROR 511 (42890): All ORDER BY expressions must appear in SELECT DISTINCT: STOREID (state=42890,code=511) java.sql.SQLException: ERROR 511 (42890): All ORDER BY expressions must appear in SELECT DISTINCT: STOREID at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:483) at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:150) at org.apache.phoenix.compile.OrderByCompiler.compile(OrderByCompiler.java:130) at org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:562) at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:507) at org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:202) {code} But if I wrap it into dumb sub-middle-query, then phoenix allows to run it: {code} 0: jdbc:phoenix:localhost:2181:/hbase> explain select id, ts, substr(product, 1, 20) from product_history_v3 where (id, ts) in (select id, ts from (select id, ts from product_history_v3 where merchantid = '1479114284851799852-2-11-118-1577502676' and ts > 1514425550000 order by storeid, id, ts limit 500)) order by storeid, id, ts; +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | CLIENT 1460-CHUNK 62355620 ROWS 452990608697 BYTES PARALLEL 1460-WAY FULL SCAN OVER PRODUCT_HISTORY_V3 | SERVER SORTED BY [PRODUCT_HISTORY_V3.STOREID, PRODUCT_HISTORY_V3.ID, PRODUCT_HISTORY_V3.TS] | CLIENT MERGE SORT | SKIP-SCAN-JOIN TABLE 0 | CLIENT 20-CHUNK 56910809 ROWS 6291457528 BYTES PARALLEL 20-WAY RANGE SCAN OVER PRODUCT_HISTORY_V3 [2,'1479114284851799852-2-11-118-1577502676',1514425550001] - [2,'1479114284851799852-2-11-118-1577502676',*] | SERVER FILTER BY FIRST KEY ONLY | SERVER TOP 500 ROWS SORTED BY ["STOREID", "ID", "TS"] | CLIENT MERGE SORT | CLIENT LIMIT 500 | CLIENT SORTED BY [ID, TS] | CLIENT AGGREGATE INTO DISTINCT ROWS BY [ID, TS] | DYNAMIC SERVER FILTER BY (PRODUCT_HISTORY_V3.TS, PRODUCT_HISTORY_V3.ID) IN (($5.$8, $5.$7)) +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 12 rows selected (0,306 seconds) {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)