You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ad...@apache.org on 2020/04/27 15:39:52 UTC

[cassandra] branch cassandra-3.0 updated: Fix infinite loop on index query paging in tables with clustering

This is an automated email from the ASF dual-hosted git repository.

adelapena pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
     new 6cd2d07  Fix infinite loop on index query paging in tables with clustering
6cd2d07 is described below

commit 6cd2d07d9ae00fafa460fa1613264c43a283e24d
Author: Andrés de la Peña <a....@gmail.com>
AuthorDate: Mon Apr 27 15:01:31 2020 +0100

    Fix infinite loop on index query paging in tables with clustering
    
    patch by Andres de la Peña; reviewed by Benjamin Lerer for CASSANDRA-14242
---
 CHANGES.txt                                        |   1 +
 .../service/pager/AbstractQueryPager.java          |  26 ++-
 .../service/pager/MultiPartitionPager.java         |   6 +-
 .../service/pager/PartitionRangeQueryPager.java    |   5 +
 .../cassandra/cql3/DistinctQueryPagingTest.java    | 260 +++++++++++++++++++++
 .../cassandra/cql3/IndexQueryPagingTest.java       |  26 +++
 .../cql3/validation/operations/SelectTest.java     | 158 -------------
 7 files changed, 318 insertions(+), 164 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 8d1c8ef..efe35a7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.21
+ * Fix infinite loop on index query paging in tables with clustering (CASSANDRA-14242)
  * cqlsh return non-zero status when STDIN CQL fails (CASSANDRA-15623)
  * Don't skip sstables in slice queries based only on local min/max/deletion timestamp (CASSANDRA-15690)
  * Memtable memory allocations may deadlock (CASSANDRA-15367)
diff --git a/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java b/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java
index f44aa24..2eecfee 100644
--- a/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java
+++ b/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java
@@ -67,7 +67,13 @@ abstract class AbstractQueryPager implements QueryPager
 
         pageSize = Math.min(pageSize, remaining);
         Pager pager = new RowPager(limits.forPaging(pageSize), command.nowInSec());
-        return Transformation.apply(nextPageReadCommand(pageSize).execute(consistency, clientState), pager);
+        ReadCommand readCommand = nextPageReadCommand(pageSize);
+        if (readCommand == null)
+        {
+            exhausted = true;
+            return EmptyIterators.partition();
+        }
+        return Transformation.apply(readCommand.execute(consistency, clientState), pager);
     }
 
     public PartitionIterator fetchPageInternal(int pageSize, ReadOrderGroup orderGroup) throws RequestValidationException, RequestExecutionException
@@ -77,7 +83,13 @@ abstract class AbstractQueryPager implements QueryPager
 
         pageSize = Math.min(pageSize, remaining);
         RowPager pager = new RowPager(limits.forPaging(pageSize), command.nowInSec());
-        return Transformation.apply(nextPageReadCommand(pageSize).executeInternal(orderGroup), pager);
+        ReadCommand readCommand = nextPageReadCommand(pageSize);
+        if (readCommand == null)
+        {
+            exhausted = true;
+            return EmptyIterators.partition();
+        }
+        return Transformation.apply(readCommand.executeInternal(orderGroup), pager);
     }
 
     public UnfilteredPartitionIterator fetchPageUnfiltered(CFMetaData cfm, int pageSize, ReadOrderGroup orderGroup)
@@ -86,9 +98,15 @@ abstract class AbstractQueryPager implements QueryPager
             return EmptyIterators.unfilteredPartition(cfm, false);
 
         pageSize = Math.min(pageSize, remaining);
-        UnfilteredPager pager = new UnfilteredPager(limits.forPaging(pageSize), command.nowInSec());
 
-        return Transformation.apply(nextPageReadCommand(pageSize).executeLocally(orderGroup), pager);
+        ReadCommand readCommand = nextPageReadCommand(pageSize);
+        if (readCommand == null)
+        {
+            exhausted = true;
+            return EmptyIterators.unfilteredPartition(cfm, false);
+        }
+        UnfilteredPager pager = new UnfilteredPager(limits.forPaging(pageSize), command.nowInSec());
+        return Transformation.apply(readCommand.executeLocally(orderGroup), pager);
     }
 
     private class UnfilteredPager extends Pager<Unfiltered>
diff --git a/src/java/org/apache/cassandra/service/pager/MultiPartitionPager.java b/src/java/org/apache/cassandra/service/pager/MultiPartitionPager.java
index 344c64d..aa268ab 100644
--- a/src/java/org/apache/cassandra/service/pager/MultiPartitionPager.java
+++ b/src/java/org/apache/cassandra/service/pager/MultiPartitionPager.java
@@ -90,8 +90,10 @@ public class MultiPartitionPager implements QueryPager
         if (isExhausted())
             return null;
 
-        PagingState state = pagers[current].state();
-        return new PagingState(pagers[current].key(), state == null ? null : state.rowMark, remaining, Integer.MAX_VALUE);
+        SinglePartitionPager pager = pagers[current];
+        PagingState pagerState = pager.state();
+        // Multi-partition paging state represents a _current_ position.
+        return new PagingState(pager.key(), pagerState == null ? null : pagerState.rowMark, remaining, pager.remainingInPartition());
     }
 
     public boolean isExhausted()
diff --git a/src/java/org/apache/cassandra/service/pager/PartitionRangeQueryPager.java b/src/java/org/apache/cassandra/service/pager/PartitionRangeQueryPager.java
index aed5a23..bee4a1e 100644
--- a/src/java/org/apache/cassandra/service/pager/PartitionRangeQueryPager.java
+++ b/src/java/org/apache/cassandra/service/pager/PartitionRangeQueryPager.java
@@ -69,6 +69,11 @@ public class PartitionRangeQueryPager extends AbstractQueryPager
             pageRange = fullRange;
             limits = command.limits().forPaging(pageSize);
         }
+        // if the last key was the one of the end of the range we know that we are done
+        else if (lastReturnedKey.equals(fullRange.keyRange().right) && remainingInPartition() == 0 && lastReturnedRow == null)
+        {
+            return null;
+        }
         else
         {
             // We want to include the last returned key only if we haven't achieved our per-partition limit, otherwise, don't bother.
diff --git a/test/unit/org/apache/cassandra/cql3/DistinctQueryPagingTest.java b/test/unit/org/apache/cassandra/cql3/DistinctQueryPagingTest.java
new file mode 100644
index 0000000..f433179
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql3/DistinctQueryPagingTest.java
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.cql3;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DistinctQueryPagingTest extends CQLTester
+{
+    /**
+     * Migrated from cql_tests.py:TestCQL.test_select_distinct()
+     */
+    @Test
+    public void testSelectDistinct() throws Throwable
+    {
+        // Test a regular (CQL3) table.
+        createTable("CREATE TABLE %s (pk0 int, pk1 int, ck0 int, val int, PRIMARY KEY((pk0, pk1), ck0))");
+
+        for (int i = 0; i < 3; i++)
+        {
+            execute("INSERT INTO %s (pk0, pk1, ck0, val) VALUES (?, ?, 0, 0)", i, i);
+            execute("INSERT INTO %s (pk0, pk1, ck0, val) VALUES (?, ?, 1, 1)", i, i);
+        }
+
+        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 1"),
+                   row(0, 0));
+
+        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 3"),
+                   row(0, 0),
+                   row(2, 2),
+                   row(1, 1));
+
+        // Test selection validation.
+        assertInvalidMessage("queries must request all the partition key columns", "SELECT DISTINCT pk0 FROM %s");
+        assertInvalidMessage("queries must only request partition key columns", "SELECT DISTINCT pk0, pk1, ck0 FROM %s");
+
+        // Test a 'compact storage' table.
+        createTable("CREATE TABLE %s (pk0 int, pk1 int, val int, PRIMARY KEY((pk0, pk1))) WITH COMPACT STORAGE");
+
+        for (int i = 0; i < 3; i++)
+            execute("INSERT INTO %s (pk0, pk1, val) VALUES (?, ?, ?)", i, i, i);
+
+        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 1"),
+                   row(0, 0));
+
+        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 3"),
+                   row(0, 0),
+                   row(2, 2),
+                   row(1, 1));
+
+        // Test a 'wide row' thrift table.
+        createTable("CREATE TABLE %s (pk int, name text, val int, PRIMARY KEY(pk, name)) WITH COMPACT STORAGE");
+
+        for (int i = 0; i < 3; i++)
+        {
+            execute("INSERT INTO %s (pk, name, val) VALUES (?, 'name0', 0)", i);
+            execute("INSERT INTO %s (pk, name, val) VALUES (?, 'name1', 1)", i);
+        }
+
+        assertRows(execute("SELECT DISTINCT pk FROM %s LIMIT 1"),
+                   row(1));
+
+        assertRows(execute("SELECT DISTINCT pk FROM %s LIMIT 3"),
+                   row(1),
+                   row(0),
+                   row(2));
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.test_select_distinct_with_deletions()
+     */
+    @Test
+    public void testSelectDistinctWithDeletions() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, c int, v int)");
+
+        for (int i = 0; i < 10; i++)
+            execute("INSERT INTO %s (k, c, v) VALUES (?, ?, ?)", i, i, i);
+
+        Object[][] rows = getRows(execute("SELECT DISTINCT k FROM %s"));
+        Assert.assertEquals(10, rows.length);
+        Object key_to_delete = rows[3][0];
+
+        execute("DELETE FROM %s WHERE k=?", key_to_delete);
+
+        rows = getRows(execute("SELECT DISTINCT k FROM %s"));
+        Assert.assertEquals(9, rows.length);
+
+        rows = getRows(execute("SELECT DISTINCT k FROM %s LIMIT 5"));
+        Assert.assertEquals(5, rows.length);
+
+        rows = getRows(execute("SELECT DISTINCT k FROM %s"));
+        Assert.assertEquals(9, rows.length);
+    }
+
+    @Test
+    public void testSelectDistinctWithWhereClause() throws Throwable {
+        createTable("CREATE TABLE %s (k int, a int, b int, PRIMARY KEY (k, a))");
+        createIndex("CREATE INDEX ON %s (b)");
+
+        for (int i = 0; i < 10; i++)
+        {
+            execute("INSERT INTO %s (k, a, b) VALUES (?, ?, ?)", i, i, i);
+            execute("INSERT INTO %s (k, a, b) VALUES (?, ?, ?)", i, i * 10, i * 10);
+        }
+
+        String distinctQueryErrorMsg = "SELECT DISTINCT with WHERE clause only supports restriction by partition key and/or static columns.";
+        assertInvalidMessage(distinctQueryErrorMsg,
+                             "SELECT DISTINCT k FROM %s WHERE a >= 80 ALLOW FILTERING");
+
+        assertInvalidMessage(distinctQueryErrorMsg,
+                             "SELECT DISTINCT k FROM %s WHERE k IN (1, 2, 3) AND a = 10");
+
+        assertInvalidMessage(distinctQueryErrorMsg,
+                             "SELECT DISTINCT k FROM %s WHERE b = 5");
+
+        assertRows(execute("SELECT DISTINCT k FROM %s WHERE k = 1"),
+                   row(1));
+        assertRows(execute("SELECT DISTINCT k FROM %s WHERE k IN (5, 6, 7)"),
+                   row(5),
+                   row(6),
+                   row(7));
+
+        // With static columns
+        createTable("CREATE TABLE %s (k int, a int, s int static, b int, PRIMARY KEY (k, a))");
+        createIndex("CREATE INDEX ON %s (b)");
+        for (int i = 0; i < 10; i++)
+        {
+            execute("INSERT INTO %s (k, a, b, s) VALUES (?, ?, ?, ?)", i, i, i, i);
+            execute("INSERT INTO %s (k, a, b, s) VALUES (?, ?, ?, ?)", i, i * 10, i * 10, i * 10);
+        }
+
+        assertRows(execute("SELECT DISTINCT s FROM %s WHERE k = 5"),
+                   row(50));
+        assertRows(execute("SELECT DISTINCT s FROM %s WHERE k IN (5, 6, 7)"),
+                   row(50),
+                   row(60),
+                   row(70));
+    }
+
+    @Test
+    public void testSelectDistinctWithWhereClauseOnStaticColumn() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int, a int, s int static, s1 int static, b int, PRIMARY KEY (k, a))");
+
+        for (int i = 0; i < 10; i++)
+        {
+            execute("INSERT INTO %s (k, a, b, s, s1) VALUES (?, ?, ?, ?, ?)", i, i, i, i, i);
+            execute("INSERT INTO %s (k, a, b, s, s1) VALUES (?, ?, ?, ?, ?)", i, i * 10, i * 10, i * 10, i * 10);
+        }
+
+        execute("INSERT INTO %s (k, a, b, s, s1) VALUES (?, ?, ?, ?, ?)", 2, 10, 10, 10, 10);
+
+        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE s = 90 AND s1 = 90 ALLOW FILTERING"),
+                   row(9, 90, 90));
+
+        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE s = 90 AND s1 = 90 ALLOW FILTERING"),
+                   row(9, 90, 90));
+
+        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE s = 10 AND s1 = 10 ALLOW FILTERING"),
+                   row(1, 10, 10),
+                   row(2, 10, 10));
+
+        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE k = 1 AND s = 10 AND s1 = 10 ALLOW FILTERING"),
+                   row(1, 10, 10));
+    }
+
+    @Test
+    public void testSelectDistinctWithStaticColumnsAndPaging() throws Throwable
+    {
+        createTable("CREATE TABLE %s (a int, b int, s int static, c int, d int, primary key (a, b));");
+
+        // Test with only static data
+        for (int i = 0; i < 5; i++)
+            execute("INSERT INTO %s (a, s) VALUES (?, ?)", i, i);
+
+        testSelectDistinctWithPaging();
+
+        // Test with a mix of partition with rows and partitions without rows
+        for (int i = 0; i < 5; i++)
+        {
+            if (i % 2 == 0)
+            {
+                for (int j = 1; j < 4; j++)
+                {
+                    execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", i, j, j, i + j);
+                }
+            }
+        }
+
+        testSelectDistinctWithPaging();
+
+        // Test with all partition with rows
+        for (int i = 0; i < 5; i++)
+        {
+            for (int j = 1; j < 4; j++)
+            {
+                execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", i, j, j, i + j);
+            }
+        }
+
+        testSelectDistinctWithPaging();
+    }
+
+    private void testSelectDistinctWithPaging() throws Throwable
+    {
+        for (int pageSize = 1; pageSize < 7; pageSize++)
+        {
+            // Range query
+            assertRowsNet(executeNetWithPaging("SELECT DISTINCT a, s FROM %s", pageSize),
+                          row(1, 1),
+                          row(0, 0),
+                          row(2, 2),
+                          row(4, 4),
+                          row(3, 3));
+
+            assertRowsNet(executeNetWithPaging("SELECT DISTINCT a, s FROM %s LIMIT 3", pageSize),
+                          row(1, 1),
+                          row(0, 0),
+                          row(2, 2));
+
+            assertRowsNet(executeNetWithPaging("SELECT DISTINCT a, s FROM %s WHERE s >= 2 ALLOW FILTERING", pageSize),
+                          row(2, 2),
+                          row(4, 4),
+                          row(3, 3));
+
+            // Multi partition query
+            assertRowsNet(executeNetWithPaging("SELECT DISTINCT a, s FROM %s WHERE a IN (1, 2, 3, 4);", pageSize),
+                          row(1, 1),
+                          row(2, 2),
+                          row(3, 3),
+                          row(4, 4));
+
+            assertRowsNet(executeNetWithPaging("SELECT DISTINCT a, s FROM %s WHERE a IN (1, 2, 3, 4) LIMIT 3;", pageSize),
+                          row(1, 1),
+                          row(2, 2),
+                          row(3, 3));
+
+            assertRowsNet(executeNetWithPaging("SELECT DISTINCT a, s FROM %s WHERE a IN (1, 2, 3, 4) AND s >= 2 ALLOW FILTERING;", pageSize),
+                          row(2, 2),
+                          row(3, 3),
+                          row(4, 4));
+        }
+    }
+}
diff --git a/test/unit/org/apache/cassandra/cql3/IndexQueryPagingTest.java b/test/unit/org/apache/cassandra/cql3/IndexQueryPagingTest.java
index 238a58d..fd1e661 100644
--- a/test/unit/org/apache/cassandra/cql3/IndexQueryPagingTest.java
+++ b/test/unit/org/apache/cassandra/cql3/IndexQueryPagingTest.java
@@ -91,6 +91,32 @@ public class IndexQueryPagingTest extends CQLTester
         executePagingQuery("SELECT * FROM %s WHERE k1=0 AND c1>=0 AND c1<=3 AND v1=0", rowCount);
     }
 
+    @Test
+    public void testPagingOnPartitionsWithoutClusteringColumns() throws Throwable
+    {
+        createTable("CREATE TABLE %s (pk int PRIMARY KEY, v int)");
+        createIndex("CREATE INDEX on %s(v)");
+
+        execute("INSERT INTO %s (pk, v) VALUES (201, 200);");
+        execute("INSERT INTO %s (pk, v) VALUES (202, 200);");
+        execute("INSERT INTO %s (pk, v) VALUES (203, 200);");
+        execute("INSERT INTO %s (pk, v) VALUES (100, 100);");
+
+        for (int pageSize = 1; pageSize < 10; pageSize++)
+        {
+            assertRowsNet(executeNetWithPaging("select * from %s where v = 200 and pk = 201;", pageSize),
+                          row(201, 200));
+
+            assertRowsNet(executeNetWithPaging("select * from %s where v = 200;", pageSize),
+                          row(201, 200),
+                          row(203, 200),
+                          row(202, 200));
+
+            assertRowsNet(executeNetWithPaging("select * from %s where v = 100;", pageSize),
+                          row(100, 100));
+        }
+    }
+
     private void executePagingQuery(String cql, int rowCount)
     {
         // Execute an index query which should return all rows,
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
index f88dd2f..469e8ca 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
@@ -1170,164 +1170,6 @@ public class SelectTest extends CQLTester
     }
 
     /**
-     * Migrated from cql_tests.py:TestCQL.select_distinct_test()
-     */
-    @Test
-    public void testSelectDistinct() throws Throwable
-    {
-        // Test a regular(CQL3) table.
-        createTable("CREATE TABLE %s (pk0 int, pk1 int, ck0 int, val int, PRIMARY KEY((pk0, pk1), ck0))");
-
-        for (int i = 0; i < 3; i++)
-        {
-            execute("INSERT INTO %s (pk0, pk1, ck0, val) VALUES (?, ?, 0, 0)", i, i);
-            execute("INSERT INTO %s (pk0, pk1, ck0, val) VALUES (?, ?, 1, 1)", i, i);
-        }
-
-        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 1"),
-                   row(0, 0));
-
-        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 3"),
-                   row(0, 0),
-                   row(2, 2),
-                   row(1, 1));
-
-        // Test selection validation.
-        assertInvalidMessage("queries must request all the partition key columns", "SELECT DISTINCT pk0 FROM %s");
-        assertInvalidMessage("queries must only request partition key columns", "SELECT DISTINCT pk0, pk1, ck0 FROM %s");
-
-        //Test a 'compact storage' table.
-        createTable("CREATE TABLE %s (pk0 int, pk1 int, val int, PRIMARY KEY((pk0, pk1))) WITH COMPACT STORAGE");
-
-        for (int i = 0; i < 3; i++)
-            execute("INSERT INTO %s (pk0, pk1, val) VALUES (?, ?, ?)", i, i, i);
-
-        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 1"),
-                   row(0, 0));
-
-        assertRows(execute("SELECT DISTINCT pk0, pk1 FROM %s LIMIT 3"),
-                   row(0, 0),
-                   row(2, 2),
-                   row(1, 1));
-
-        // Test a 'wide row' thrift table.
-        createTable("CREATE TABLE %s (pk int, name text, val int, PRIMARY KEY(pk, name)) WITH COMPACT STORAGE");
-
-        for (int i = 0; i < 3; i++)
-        {
-            execute("INSERT INTO %s (pk, name, val) VALUES (?, 'name0', 0)", i);
-            execute("INSERT INTO %s (pk, name, val) VALUES (?, 'name1', 1)", i);
-        }
-
-        assertRows(execute("SELECT DISTINCT pk FROM %s LIMIT 1"),
-                   row(1));
-
-        assertRows(execute("SELECT DISTINCT pk FROM %s LIMIT 3"),
-                   row(1),
-                   row(0),
-                   row(2));
-    }
-
-    /**
-     * Migrated from cql_tests.py:TestCQL.select_distinct_with_deletions_test()
-     */
-    @Test
-    public void testSelectDistinctWithDeletions() throws Throwable
-    {
-        createTable("CREATE TABLE %s (k int PRIMARY KEY, c int, v int)");
-
-        for (int i = 0; i < 10; i++)
-            execute("INSERT INTO %s (k, c, v) VALUES (?, ?, ?)", i, i, i);
-
-        Object[][] rows = getRows(execute("SELECT DISTINCT k FROM %s"));
-        Assert.assertEquals(10, rows.length);
-        Object key_to_delete = rows[3][0];
-
-        execute("DELETE FROM %s WHERE k=?", key_to_delete);
-
-        rows = getRows(execute("SELECT DISTINCT k FROM %s"));
-        Assert.assertEquals(9, rows.length);
-
-        rows = getRows(execute("SELECT DISTINCT k FROM %s LIMIT 5"));
-        Assert.assertEquals(5, rows.length);
-
-        rows = getRows(execute("SELECT DISTINCT k FROM %s"));
-        Assert.assertEquals(9, rows.length);
-    }
-
-    @Test
-    public void testSelectDistinctWithWhereClause() throws Throwable {
-        createTable("CREATE TABLE %s (k int, a int, b int, PRIMARY KEY (k, a))");
-        createIndex("CREATE INDEX ON %s (b)");
-
-        for (int i = 0; i < 10; i++)
-        {
-            execute("INSERT INTO %s (k, a, b) VALUES (?, ?, ?)", i, i, i);
-            execute("INSERT INTO %s (k, a, b) VALUES (?, ?, ?)", i, i * 10, i * 10);
-        }
-
-        String distinctQueryErrorMsg = "SELECT DISTINCT with WHERE clause only supports restriction by partition key and/or static columns.";
-        assertInvalidMessage(distinctQueryErrorMsg,
-                             "SELECT DISTINCT k FROM %s WHERE a >= 80 ALLOW FILTERING");
-
-        assertInvalidMessage(distinctQueryErrorMsg,
-                             "SELECT DISTINCT k FROM %s WHERE k IN (1, 2, 3) AND a = 10");
-
-        assertInvalidMessage(distinctQueryErrorMsg,
-                             "SELECT DISTINCT k FROM %s WHERE b = 5");
-
-        assertRows(execute("SELECT DISTINCT k FROM %s WHERE k = 1"),
-                   row(1));
-        assertRows(execute("SELECT DISTINCT k FROM %s WHERE k IN (5, 6, 7)"),
-                   row(5),
-                   row(6),
-                   row(7));
-
-        // With static columns
-        createTable("CREATE TABLE %s (k int, a int, s int static, b int, PRIMARY KEY (k, a))");
-        createIndex("CREATE INDEX ON %s (b)");
-        for (int i = 0; i < 10; i++)
-        {
-            execute("INSERT INTO %s (k, a, b, s) VALUES (?, ?, ?, ?)", i, i, i, i);
-            execute("INSERT INTO %s (k, a, b, s) VALUES (?, ?, ?, ?)", i, i * 10, i * 10, i * 10);
-        }
-
-        assertRows(execute("SELECT DISTINCT s FROM %s WHERE k = 5"),
-                   row(50));
-        assertRows(execute("SELECT DISTINCT s FROM %s WHERE k IN (5, 6, 7)"),
-                   row(50),
-                   row(60),
-                   row(70));
-    }
-
-    @Test
-    public void testSelectDistinctWithWhereClauseOnStaticColumn() throws Throwable
-    {
-        createTable("CREATE TABLE %s (k int, a int, s int static, s1 int static, b int, PRIMARY KEY (k, a))");
-
-        for (int i = 0; i < 10; i++)
-        {
-            execute("INSERT INTO %s (k, a, b, s, s1) VALUES (?, ?, ?, ?, ?)", i, i, i, i, i);
-            execute("INSERT INTO %s (k, a, b, s, s1) VALUES (?, ?, ?, ?, ?)", i, i * 10, i * 10, i * 10, i * 10);
-        }
-
-        execute("INSERT INTO %s (k, a, b, s, s1) VALUES (?, ?, ?, ?, ?)", 2, 10, 10, 10, 10);
-
-        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE s = 90 AND s1 = 90 ALLOW FILTERING"),
-                   row(9, 90, 90));
-
-        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE s = 90 AND s1 = 90 ALLOW FILTERING"),
-                   row(9, 90, 90));
-
-        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE s = 10 AND s1 = 10 ALLOW FILTERING"),
-                   row(1, 10, 10),
-                   row(2, 10, 10));
-
-        assertRows(execute("SELECT DISTINCT k, s, s1 FROM %s WHERE k = 1 AND s = 10 AND s1 = 10 ALLOW FILTERING"),
-                   row(1, 10, 10));
-    }
-
-    /**
      * Migrated from cql_tests.py:TestCQL.bug_6327_test()
      */
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org