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 222A3200CC5 for ; Mon, 26 Jun 2017 13:32:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 20CEB160BD9; Mon, 26 Jun 2017 11:32:47 +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 68801160BDE for ; Mon, 26 Jun 2017 13:32:46 +0200 (CEST) Received: (qmail 36219 invoked by uid 500); 26 Jun 2017 11:32:45 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 36178 invoked by uid 99); 26 Jun 2017 11:32:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Jun 2017 11:32:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 508C8E03B3; Mon, 26 Jun 2017 11:32:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: blerer@apache.org To: commits@cassandra.apache.org Date: Mon, 26 Jun 2017 11:32:45 -0000 Message-Id: <7d571ac5ced441ea88f13116de71b736@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/6] cassandra git commit: Fix secondary index queries on COMPACT tables archived-at: Mon, 26 Jun 2017 11:32:47 -0000 Fix secondary index queries on COMPACT tables patch by Benjamin Lerer; reviewed by Andrés de la Peña for CASSANDRA-13627 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/57c590f6 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/57c590f6 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/57c590f6 Branch: refs/heads/cassandra-3.11 Commit: 57c590f6f71907dda6f3d88a16883b5dbcf259ee Parents: 96bd3d5 Author: Benjamin Lerer Authored: Mon Jun 26 13:14:46 2017 +0200 Committer: Benjamin Lerer Committed: Mon Jun 26 13:14:46 2017 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/cql3/selection/Selection.java | 2 +- .../validation/entities/SecondaryIndexTest.java | 43 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/57c590f6/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 00e87bf..d90d220 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.15 + * Fix secondary index queries on COMPACT tables (CASSANDRA-13627) * Nodetool listsnapshots output is missing a newline, if there are no snapshots (CASSANDRA-13568) http://git-wip-us.apache.org/repos/asf/cassandra/blob/57c590f6/src/java/org/apache/cassandra/cql3/selection/Selection.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/selection/Selection.java b/src/java/org/apache/cassandra/cql3/selection/Selection.java index 8a27314..0ecf063 100644 --- a/src/java/org/apache/cassandra/cql3/selection/Selection.java +++ b/src/java/org/apache/cassandra/cql3/selection/Selection.java @@ -81,7 +81,7 @@ public abstract class Selection */ public boolean containsStaticColumns() { - if (!cfm.hasStaticColumns()) + if (cfm.isStaticCompactTable() || !cfm.hasStaticColumns()) return false; if (isWildcard()) http://git-wip-us.apache.org/repos/asf/cassandra/blob/57c590f6/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java index 1a1b881..0f6cba7 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java @@ -1273,4 +1273,47 @@ public class SecondaryIndexTest extends CQLTester assertEmpty(execute("SELECT * FROM %s WHERE a = 3")); assertEmpty(execute("SELECT * FROM %s WHERE a = 5")); } + + @Test + public void testIndicesOnCompactTable() throws Throwable + { + assertInvalidMessage("COMPACT STORAGE with composite PRIMARY KEY allows no more than one column not part of the PRIMARY KEY (got: v1, v2)", + "CREATE TABLE test (pk int, c int, v1 int, v2 int, PRIMARY KEY(pk, c)) WITH COMPACT STORAGE"); + + createTable("CREATE TABLE %s (pk int, c int, v int, PRIMARY KEY(pk, c)) WITH COMPACT STORAGE"); + assertInvalidMessage("Secondary indexes are not supported on COMPACT STORAGE tables that have clustering columns", + "CREATE INDEX ON %s(v)"); + + createTable("CREATE TABLE %s (pk int PRIMARY KEY, v int) WITH COMPACT STORAGE"); + createIndex("CREATE INDEX ON %s(v)"); + + execute("INSERT INTO %s (pk, v) VALUES (?, ?)", 1, 1); + execute("INSERT INTO %s (pk, v) VALUES (?, ?)", 2, 1); + execute("INSERT INTO %s (pk, v) VALUES (?, ?)", 3, 3); + + assertRows(execute("SELECT pk, v FROM %s WHERE v = 1"), + row(1, 1), + row(2, 1)); + + assertRows(execute("SELECT pk, v FROM %s WHERE v = 3"), + row(3, 3)); + + assertEmpty(execute("SELECT pk, v FROM %s WHERE v = 5")); + + createTable("CREATE TABLE %s (pk int PRIMARY KEY, v1 int, v2 int) WITH COMPACT STORAGE"); + createIndex("CREATE INDEX ON %s(v1)"); + + execute("INSERT INTO %s (pk, v1, v2) VALUES (?, ?, ?)", 1, 1, 1); + execute("INSERT INTO %s (pk, v1, v2) VALUES (?, ?, ?)", 2, 1, 2); + execute("INSERT INTO %s (pk, v1, v2) VALUES (?, ?, ?)", 3, 3, 3); + + assertRows(execute("SELECT pk, v2 FROM %s WHERE v1 = 1"), + row(1, 1), + row(2, 2)); + + assertRows(execute("SELECT pk, v2 FROM %s WHERE v1 = 3"), + row(3, 3)); + + assertEmpty(execute("SELECT pk, v2 FROM %s WHERE v1 = 5")); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org For additional commands, e-mail: commits-help@cassandra.apache.org