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 3485D200CC4 for ; Thu, 13 Jul 2017 15:20:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 32E1116C056; Thu, 13 Jul 2017 13:20:10 +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 526B916C055 for ; Thu, 13 Jul 2017 15:20:09 +0200 (CEST) Received: (qmail 63096 invoked by uid 500); 13 Jul 2017 13:20:08 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 63070 invoked by uid 99); 13 Jul 2017 13:20:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jul 2017 13:20:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id C3BE3196265 for ; Thu, 13 Jul 2017 13:20:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-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, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id IaOdJyyO9qgI for ; Thu, 13 Jul 2017 13:20:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 772025FDAD for ; Thu, 13 Jul 2017 13:20:05 +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 F08B9E0984 for ; Thu, 13 Jul 2017 13:20:03 +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 5EA1924738 for ; Thu, 13 Jul 2017 13:20:01 +0000 (UTC) Date: Thu, 13 Jul 2017 13:20:01 +0000 (UTC) From: "Benjamin Lerer (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CASSANDRA-11223) Queries with LIMIT filtering on clustering columns can return less rows than expected MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 13 Jul 2017 13:20:10 -0000 [ https://issues.apache.org/jira/browse/CASSANDRA-11223?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId= =3D16085685#comment-16085685 ]=20 Benjamin Lerer commented on CASSANDRA-11223: -------------------------------------------- {quote}I missed it last time sorry, but we should not count the static row = in {{GroupByPrefixReversed.count()}} when {{countPartitionsWithOnlyStaticDa= ta}} is false.{quote} I did not change it on purpose. The problem only affect range queries and multi-partition queries. Range qu= eries do not accept an {{ORDER BY}} clause. Multi-partition queries only ac= cept an {{ORDER BY}} clause when paging is off. The limit in this case is u= sed only when the rows with only static data have already been discarded. S= o, in practice changing {{GroupByPrefixReversed.count()}} has no effect. I will add a test to prove that the behavior is correct. {quote}Are we sure it's fine to always count the static row in {{ColumnFami= ly.liveCQL3RowCount()}}?{quote} {{ColumnFamily.liveCQL3RowCount()}} is only used by {{ColumnFamilyStore::is= FilterFullyCoveredBy}} to check if the whole partition is cached. That we c= ount the static row or not, the answer will be correct. We could argue about {{ColumnFamily.liveCQL3RowCount()}} independently of i= ts current use, but I am in favor of minimizing the changes on {{2.2}} (tak= en into account that everything is different in {{3.0}}). What do you think= ? {quote}Should we count static rows for the limits used by {{RowCacheSeriali= zer.deserialize()}}?{quote} I think it is fine. The limit is only used for limiting the number of rows = stored in the cache for each partition and we will only count the static ro= w if the partition does not have any row. =20 =20 {quote}I haven't checked the 3.11 and trunk patches yet, did they apply or = do they need a full review?{quote} {{3.11}} is different due to the {{GROUP BY}} functionality. =20 I pushed the updated branches. > Queries with LIMIT filtering on clustering columns can return less rows t= han expected > -------------------------------------------------------------------------= ------------ > > Key: CASSANDRA-11223 > URL: https://issues.apache.org/jira/browse/CASSANDRA-1122= 3 > Project: Cassandra > Issue Type: Bug > Components: Local Write-Read Paths > Reporter: Benjamin Lerer > Assignee: Benjamin Lerer > > A query like {{SELECT * FROM %s WHERE b =3D 1 LIMIT 2 ALLOW FILTERING}} c= an return less row than expected if the table has some static columns and s= ome of the partition have no rows matching b =3D 1. > The problem can be reproduced with the following unit test: > {code} > =E2=80=82=E2=80=82=E2=80=82=E2=80=82public void testFilteringOnClustering= ColumnsWithLimitAndStaticColumns() throws Throwable > =E2=80=82=E2=80=82=E2=80=82=E2=80=82{ > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82c= reateTable("CREATE TABLE %s (a int, b int, s int static, c int, primary key= (a, b))"); > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82f= or (int i =3D 0; i < 3; i++) > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82{ > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82execute("INSERT INTO %s (a, s) VALUES (= ?, ?)", i, i); > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82for= (int j =3D 0; j < 3; j++) > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82if (!(i =3D=3D 0 && j =3D=3D 1)) > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82execut= e("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", i, j, i + j); > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82} > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= ssertRows(execute("SELECT * FROM %s"), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(1, 0, 1, 1), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(1, 1, 1, 2), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(1, 2, 1, 3), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(0, 0, 0, 0), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(0, 2, 0, 2), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(2, 0, 2, 2), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(2, 1, 2, 3), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(2, 2, 2, 4)); > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= ssertRows(execute("SELECT * FROM %s WHERE b =3D 1 ALLOW FILTERING"), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(1, 1, 1, 2), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(2, 1, 2, 3)); > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= ssertRows(execute("SELECT * FROM %s WHERE b =3D 1 LIMIT 2 ALLOW FILTERING")= , > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(1, 1, 1, 2), > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82= =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2= =80=82=E2=80=82 row(2, 1, 2, 3)); // <-------- FAIL It returns only one row= because the static row of partition 0 is counted and filtered out in SELEC= T statement > =E2=80=82=E2=80=82=E2=80=82=E2=80=82} > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org For additional commands, e-mail: commits-help@cassandra.apache.org