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 046B0200C80 for ; Wed, 10 May 2017 12:47:39 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 026ED160BB4; Wed, 10 May 2017 10:47:39 +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 50377160BC9 for ; Wed, 10 May 2017 12:47:38 +0200 (CEST) Received: (qmail 66198 invoked by uid 500); 10 May 2017 10:47:36 -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 65959 invoked by uid 99); 10 May 2017 10:47:36 -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; Wed, 10 May 2017 10:47:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 17D65E5720; Wed, 10 May 2017 10:47:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: adelapena@apache.org To: commits@cassandra.apache.org Date: Wed, 10 May 2017 10:47:43 -0000 Message-Id: <372681c146a64981b7426b459f0fefdb@git.apache.org> In-Reply-To: <5a9785a863f3405186bf1eed69639c52@git.apache.org> References: <5a9785a863f3405186bf1eed69639c52@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [9/9] cassandra git commit: Merge branch 'cassandra-3.11' into trunk archived-at: Wed, 10 May 2017 10:47:39 -0000 Merge branch 'cassandra-3.11' into trunk Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/69aa1737 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/69aa1737 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/69aa1737 Branch: refs/heads/trunk Commit: 69aa1737d17089278c725cffeca3f69fb25f0aa0 Parents: bf1cd8e f33cdcb Author: adelapena Authored: Wed May 10 11:47:20 2017 +0100 Committer: adelapena Committed: Wed May 10 11:47:20 2017 +0100 ---------------------------------------------------------------------- .../validation/entities/SecondaryIndexTest.java | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/69aa1737/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java index c5fb45d,3aed07a..29ceb3b --- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java @@@ -1524,13 -1535,56 +1524,55 @@@ public class SecondaryIndexTest extend assertInvalidMessage("full() indexes can only be created on frozen collections", "CREATE INDEX ON %s (full(v))"); } + @Test + public void testIndexOnPartitionKeyInsertExpiringColumn() throws Throwable + { + createTable("CREATE TABLE %s (k1 int, k2 int, a int, b int, PRIMARY KEY ((k1, k2)))"); + createIndex("CREATE INDEX on %s(k1)"); + execute("INSERT INTO %s (k1, k2, a, b) VALUES (1, 2, 3, 4)"); + assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, 4)); + execute("UPDATE %s USING TTL 1 SET b = 10 WHERE k1 = 1 AND k2 = 2"); + Thread.sleep(1000); + assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, null)); + } + + @Test + public void testIndexOnClusteringKeyInsertExpiringColumn() throws Throwable + { + createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))"); + createIndex("CREATE INDEX on %s(ck)"); + execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)"); + assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, 4)); + execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2"); + Thread.sleep(1000); + assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, null)); + } + + @Test + public void testIndexOnRegularColumnInsertExpiringColumn() throws Throwable + { + createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))"); + createIndex("CREATE INDEX on %s(a)"); + execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)"); + assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, 4)); + + execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2"); + Thread.sleep(1000); + assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, null)); + + execute("UPDATE %s USING TTL 1 SET a = 5 WHERE pk = 1 AND ck = 2"); + Thread.sleep(1000); + assertEmpty(execute("SELECT * FROM %s WHERE a = 3")); + assertEmpty(execute("SELECT * FROM %s WHERE a = 5")); + } + - private ResultMessage.Prepared prepareStatement(String cql, boolean forThrift) + private ResultMessage.Prepared prepareStatement(String cql) { return QueryProcessor.prepare(String.format(cql, KEYSPACE, currentTable()), - ClientState.forInternalCalls(), - forThrift); + ClientState.forInternalCalls()); } - private void validateCell(Cell cell, ColumnDefinition def, ByteBuffer val, long timestamp) + private void validateCell(Cell cell, ColumnMetadata def, ByteBuffer val, long timestamp) { assertNotNull(cell); assertEquals(0, def.type.compare(cell.value(), val)); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org For additional commands, e-mail: commits-help@cassandra.apache.org