diff --git a/CHANGES.txt b/CHANGES.txt index 9343d66676..cc6478e3f1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0 + * Duplicate rows returned when in clause has repeated values (CASSANDRA-6707) * Make CassandraException unchecked, extend RuntimeException (CASSANDRA-8560) * Support direct buffer decompression for reads (CASSANDRA-8464) * DirectByteBuffer compatible LZ4 methods (CASSANDRA-7039) @@ -14,7 +15,7 @@ * Support for user-defined aggregation functions (CASSANDRA-8053) * Fix NPE in SelectStatement with empty IN values (CASSANDRA-8419) * Refactor SelectStatement, return IN results in natural order instead - of IN value list order (CASSANDRA-7981) + of IN value list order and ignore duplicate values in partition key IN restrictions (CASSANDRA-7981) * Support UDTs, tuples, and collections in user-defined functions (CASSANDRA-7563) * Fix aggregate fn results on empty selection, result column name, diff --git a/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java b/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java index b178498d2b..3e6e45b0b3 100644 --- a/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java +++ b/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java @@ -660,4 +660,19 @@ public class MultiColumnRelationTest extends CQLTester assertInvalidMessage("Partition key parts: b must be restricted as other parts are", "SELECT * FROM %s WHERE a = ? AND (c, d) >= (?, ?) ALLOW FILTERING", 0, 1, 1); } + + @Test + public void testINWithDuplicateValue() throws Throwable + { + for (String compactOption : new String[] { "", " WITH COMPACT STORAGE" }) + { + createTable("CREATE TABLE %s (k1 int, k2 int, v int, PRIMARY KEY (k1, k2))" + compactOption); + execute("INSERT INTO %s (k1, k2, v) VALUES (?, ?, ?)", 1, 1, 1); + + assertRows(execute("SELECT * FROM %s WHERE k1 IN (?, ?) AND (k2) IN ((?), (?))", 1, 1, 1, 2), + row(1, 1, 1)); + assertRows(execute("SELECT * FROM %s WHERE k1 = ? AND (k2) IN ((?), (?))", 1, 1, 1), + row(1, 1, 1)); + } + } } diff --git a/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java b/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java index 0fd300b6bf..f505a04d64 100644 --- a/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java +++ b/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java @@ -383,6 +383,25 @@ public class SingleColumnRelationTest extends CQLTester } } + @Test + public void testINWithDuplicateValue() throws Throwable + { + for (String compactOption : new String[] { "", " WITH COMPACT STORAGE" }) + { + createTable("CREATE TABLE %s (k1 int, k2 int, v int, PRIMARY KEY (k1, k2))" + compactOption); + execute("INSERT INTO %s (k1, k2, v) VALUES (?, ?, ?)", 1, 1, 1); + + assertRows(execute("SELECT * FROM %s WHERE k1 IN (?, ?)", 1, 1), + row(1, 1, 1)); + + assertRows(execute("SELECT * FROM %s WHERE k1 IN (?, ?) AND k2 IN (?, ?)", 1, 1, 1, 1), + row(1, 1, 1)); + + assertRows(execute("SELECT * FROM %s WHERE k1 = ? AND k2 IN (?, ?)", 1, 1, 1), + row(1, 1, 1)); + } + } + @Test public void testLargeClusteringINValues() throws Throwable { @@ -392,7 +411,6 @@ public class SingleColumnRelationTest extends CQLTester for (int i = 0; i < 10000; i++) inValues.add(i); assertRows(execute("SELECT * FROM %s WHERE k=? AND c IN ?", 0, inValues), - row(0, 0, 0) - ); + row(0, 0, 0)); } }