You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2021/11/26 06:19:07 UTC

[cassandra] branch trunk updated (951d72c -> a06eeda)

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

bereng pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from 951d72c  [CEP-10] Phase 4: Support CAS Add Operations
     new 0764273  ViewTests flaky on timeouts
     new a06eeda  Merge branch 'cassandra-4.0' into trunk

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...t.java => ViewComplexDeletionsPartialTest.java} | 239 +----------
 .../cassandra/cql3/ViewComplexDeletionsTest.java   | 198 +--------
 .../cql3/ViewComplexLivenessLimitTest.java         | 100 +++++
 .../cassandra/cql3/ViewComplexLivenessTest.java    |  66 +--
 .../apache/cassandra/cql3/ViewComplexTTLTest.java  |   4 +-
 .../org/apache/cassandra/cql3/ViewComplexTest.java |  78 +---
 .../cassandra/cql3/ViewComplexTombstoneTest.java   | 114 ++++++
 .../cassandra/cql3/ViewComplexUpdatesTest.java     |   4 +-
 ...wFilteringTest.java => ViewFiltering1Test.java} | 407 +------------------
 .../apache/cassandra/cql3/ViewFiltering2Test.java  | 452 +++++++++++++++++++++
 .../cql3/ViewFilteringClustering1Test.java         |   4 +-
 .../cql3/ViewFilteringClustering2Test.java         |   4 +-
 ...g2Test.java => ViewFilteringComplexPKTest.java} | 175 ++++----
 ...gPKTest.java => ViewFilteringSimplePKTest.java} | 244 +----------
 14 files changed, 801 insertions(+), 1288 deletions(-)
 copy test/unit/org/apache/cassandra/cql3/{ViewComplexDeletionsTest.java => ViewComplexDeletionsPartialTest.java} (50%)
 create mode 100644 test/unit/org/apache/cassandra/cql3/ViewComplexLivenessLimitTest.java
 create mode 100644 test/unit/org/apache/cassandra/cql3/ViewComplexTombstoneTest.java
 rename test/unit/org/apache/cassandra/cql3/{ViewFilteringTest.java => ViewFiltering1Test.java} (58%)
 create mode 100644 test/unit/org/apache/cassandra/cql3/ViewFiltering2Test.java
 copy test/unit/org/apache/cassandra/cql3/{ViewFilteringClustering2Test.java => ViewFilteringComplexPKTest.java} (66%)
 rename test/unit/org/apache/cassandra/cql3/{ViewFilteringPKTest.java => ViewFilteringSimplePKTest.java} (54%)

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


[cassandra] 01/01: Merge branch 'cassandra-4.0' into trunk

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bereng pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit a06eeda7f20a1afae0a65914562ce0287b45e7d6
Merge: 951d72c 0764273
Author: Bereng <be...@gmail.com>
AuthorDate: Fri Nov 26 07:17:30 2021 +0100

    Merge branch 'cassandra-4.0' into trunk

 ...t.java => ViewComplexDeletionsPartialTest.java} | 239 +----------
 .../cassandra/cql3/ViewComplexDeletionsTest.java   | 198 +--------
 .../cql3/ViewComplexLivenessLimitTest.java         | 100 +++++
 .../cassandra/cql3/ViewComplexLivenessTest.java    |  66 +--
 .../apache/cassandra/cql3/ViewComplexTTLTest.java  |   4 +-
 .../org/apache/cassandra/cql3/ViewComplexTest.java |  78 +---
 .../cassandra/cql3/ViewComplexTombstoneTest.java   | 114 ++++++
 .../cassandra/cql3/ViewComplexUpdatesTest.java     |   4 +-
 ...wFilteringTest.java => ViewFiltering1Test.java} | 407 +------------------
 .../apache/cassandra/cql3/ViewFiltering2Test.java  | 452 +++++++++++++++++++++
 .../cql3/ViewFilteringClustering1Test.java         |   4 +-
 .../cql3/ViewFilteringClustering2Test.java         |   4 +-
 ...g2Test.java => ViewFilteringComplexPKTest.java} | 175 ++++----
 ...gPKTest.java => ViewFilteringSimplePKTest.java} | 244 +----------
 14 files changed, 801 insertions(+), 1288 deletions(-)

diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsPartialTest.java
index 831f3ef,377621e..a827be3
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsPartialTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsPartialTest.java
@@@ -44,32 -33,24 +33,34 @@@ import org.apache.cassandra.utils.FBUti
   * - ViewComplexTTLTest
   * - ViewComplexTest
   * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
   */
- public class ViewComplexDeletionsTest extends ViewAbstractParameterizedTest
 -public class ViewComplexDeletionsPartialTest extends ViewComplexTester
++public class ViewComplexDeletionsPartialTest extends ViewAbstractParameterizedTest
  {
 -    // for now, unselected column cannot be fully supported, SEE CASSANDRA-11500
 +    // for now, unselected column cannot be fully supported, see CASSANDRA-11500
      @Ignore
      @Test
 -    public void testPartialDeleteUnselectedColumn() throws Throwable
 +    public void testPartialDeleteUnselectedColumnWithFlush() throws Throwable
 +    {
 +        testPartialDeleteUnselectedColumn(true);
 +    }
 +
 +    // for now, unselected column cannot be fully supported, see CASSANDRA-11500
 +    @Ignore
 +    @Test
 +    public void testPartialDeleteUnselectedColumnWithoutFlush() throws Throwable
 +    {
 +        testPartialDeleteUnselectedColumn(false);
 +    }
 +
 +    private void testPartialDeleteUnselectedColumn(boolean flush) throws Throwable
      {
 -        boolean flush = true;
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
          createTable("CREATE TABLE %s (k int, c int, a int, b int, PRIMARY KEY (k, c))");
 -        String mv = createView("CREATE MATERIALIZED VIEW %s " +
 -                                 "AS SELECT k,c FROM %%s WHERE k IS NOT NULL AND c IS NOT NULL PRIMARY KEY (k,c)");
 +        createView("CREATE MATERIALIZED VIEW %s AS " +
 +                   "SELECT k,c FROM %s WHERE k IS NOT NULL AND c IS NOT NULL PRIMARY KEY (k,c)");
          Keyspace ks = Keyspace.open(keyspace());
 -        ks.getColumnFamilyStore(mv).disableAutoCompaction();
 +        ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
  
          updateView("UPDATE %s USING TIMESTAMP 10 SET b=1 WHERE k=1 AND c=1");
          if (flush)
@@@ -236,228 -222,6 +227,6 @@@
          if (flush)
              FBUtilities.waitOnFutures(ks.flush());
  
 -        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv), row(1, 1, 1, null));
 +        assertRowsIgnoringOrder(executeView("SELECT * FROM %s"), row(1, 1, 1, null));
      }
- 
-     @Test
-     public void testCommutativeRowDeletionFlush() throws Throwable
-     {
-         // CASSANDRA-13409
-         testCommutativeRowDeletion(true);
-     }
- 
-     @Test
-     public void testCommutativeRowDeletionWithoutFlush() throws Throwable
-     {
-         // CASSANDRA-13409
-         testCommutativeRowDeletion(false);
-     }
- 
-     private void testCommutativeRowDeletion(boolean flush) throws Throwable
-     {
-         // CASSANDRA-13409 new update should not resurrect previous deleted data in view
-         createTable("create table %s (p int primary key, v1 int, v2 int)");
- 
-         Keyspace ks = Keyspace.open(keyspace());
- 
-         createView("create materialized view %s as select * from %s " +
-                      "where p is not null and v1 is not null primary key (v1, p)");
-         ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
- 
-         // sstable-1, Set initial values TS=1
-         updateView("Insert into %s (p, v1, v2) values (3, 1, 3) using timestamp 1;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v2, WRITETIME(v2) from %s WHERE v1 = ? AND p = ?", 1, 3), row(3, 1L));
-         // sstable-2
-         updateView("Delete from %s using timestamp 2 where p = 3;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"));
-         // sstable-3
-         updateView("Insert into %s (p, v1) values (3, 1) using timestamp 3;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(1, 3, null, null));
-         // sstable-4
-         updateView("UPdate %s using timestamp 4 set v1 = 2 where p = 3;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(2, 3, null, null));
-         // sstable-5
-         updateView("UPdate %s using timestamp 5 set v1 = 1 where p = 3;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(1, 3, null, null));
- 
-         if (flush)
-         {
-             // compact sstable 2 and 4, 5;
-             ColumnFamilyStore cfs = ks.getColumnFamilyStore(currentView());
-             List<String> sstables = cfs.getLiveSSTables()
-                                        .stream()
-                                        .sorted(Comparator.comparingInt(s -> s.descriptor.generation))
-                                        .map(SSTableReader::getFilename)
-                                        .collect(Collectors.toList());
-             String dataFiles = String.join(",", Arrays.asList(sstables.get(1), sstables.get(3), sstables.get(4)));
-             CompactionManager.instance.forceUserDefinedCompaction(dataFiles);
-             assertEquals(3, cfs.getLiveSSTables().size());
-         }
-         // regular tombstone should be retained after compaction
-         assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(1, 3, null, null));
-     }
- 
-     @Test
-     public void testComplexTimestampDeletionTestWithFlush() throws Throwable
-     {
-         complexTimestampWithbaseNonPKColumnsInViewPKDeletionTest(true);
-         complexTimestampWithbasePKColumnsInViewPKDeletionTest(true);
-     }
- 
-     @Test
-     public void testComplexTimestampDeletionTestWithoutFlush() throws Throwable
-     {
-         complexTimestampWithbaseNonPKColumnsInViewPKDeletionTest(false);
-         complexTimestampWithbasePKColumnsInViewPKDeletionTest(false);
-     }
- 
-     private void complexTimestampWithbasePKColumnsInViewPKDeletionTest(boolean flush) throws Throwable
-     {
-         createTable("create table %s (p1 int, p2 int, v1 int, v2 int, primary key(p1, p2))");
- 
-         Keyspace ks = Keyspace.open(keyspace());
- 
-         createView("create materialized view %s as select * from %s " +
-                      "where p1 is not null and p2 is not null primary key (p2, p1)");
-         ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
- 
-         // Set initial values TS=1
-         updateView("Insert into %s (p1, p2, v1, v2) values (1, 2, 3, 4) using timestamp 1;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, v2, WRITETIME(v2) from %s WHERE p1 = ? AND p2 = ?", 1, 2),
-                                 row(3, 4, 1L));
-         // remove row/mv TS=2
-         updateView("Delete from %s using timestamp 2 where p1 = 1 and p2 = 2;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         // view are empty
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"));
-         // insert PK with TS=3
-         updateView("Insert into %s (p1, p2) values (1, 2) using timestamp 3;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         // deleted column in MV remained dead
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"), row(2, 1, null, null));
- 
-         ks.getColumnFamilyStore(currentView()).forceMajorCompaction();
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"), row(2, 1, null, null));
- 
-         // reset values
-         updateView("Insert into %s (p1, p2, v1, v2) values (1, 2, 3, 4) using timestamp 10;");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, v2, WRITETIME(v2) from %s WHERE p1 = ? AND p2 = ?", 1, 2),
-                                 row(3, 4, 10L));
- 
-         updateView("UPDATE %s using timestamp 20 SET v2 = 5 WHERE p1 = 1 and p2 = 2");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, v2, WRITETIME(v2) from %s WHERE p1 = ? AND p2 = ?", 1, 2),
-                                 row(3, 5, 20L));
- 
-         updateView("DELETE FROM %s using timestamp 10 WHERE p1 = 1 and p2 = 2");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v1, v2, WRITETIME(v2) from %s WHERE p1 = ? AND p2 = ?", 1, 2),
-                                 row(null, 5, 20L));
-     }
- 
-     private void complexTimestampWithbaseNonPKColumnsInViewPKDeletionTest(boolean flush) throws Throwable
-     {
-         createTable("create table %s (p int primary key, v1 int, v2 int)");
- 
-         Keyspace ks = Keyspace.open(keyspace());
- 
-         createView("create materialized view %s as select * from %s " +
-                      "where p is not null and v1 is not null primary key (v1, p)");
-         ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
- 
-         // Set initial values TS=1
-         updateView("Insert into %s (p, v1, v2) values (3, 1, 5) using timestamp 1;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT v2, WRITETIME(v2) from %s WHERE v1 = ? AND p = ?", 1, 3), row(5, 1L));
-         // remove row/mv TS=2
-         updateView("Delete from %s using timestamp 2 where p = 3;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         // view are empty
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"));
-         // insert PK with TS=3
-         updateView("Insert into %s (p, v1) values (3, 1) using timestamp 3;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         // deleted column in MV remained dead
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"), row(1, 3, null));
- 
-         // insert values TS=2, it should be considered dead due to previous tombstone
-         updateView("Insert into %s (p, v1, v2) values (3, 1, 5) using timestamp 2;");
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         // deleted column in MV remained dead
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"), row(1, 3, null));
-         assertRowsIgnoringOrder(executeView("SELECT * from %s limit 1"), row(1, 3, null));
- 
-         // insert values TS=2, it should be considered dead due to previous tombstone
-         executeNet("UPDATE %s USING TIMESTAMP 3 SET v2 = ? WHERE p = ?", 4, 3);
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRows(execute("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(1, 3, 4, 3L));
- 
-         ks.getColumnFamilyStore(currentView()).forceMajorCompaction();
-         assertRows(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(1, 3, 4, 3L));
-         assertRows(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s limit 1"), row(1, 3, 4, 3L));
-     }
- 
-     @Test
-     public void testNoBatchlogCleanupForLocalMutations() throws Throwable
-     {
-         createTable("CREATE TABLE %s (k1 int primary key, v1 int)");
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                    "WHERE k1 IS NOT NULL AND v1 IS NOT NULL PRIMARY KEY (v1, k1)");
- 
-         ColumnFamilyStore batchlog = Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES);
-         batchlog.disableAutoCompaction();
-         batchlog.forceBlockingFlush();
-         int batchlogSSTables = batchlog.getLiveSSTables().size();
- 
-         updateView("INSERT INTO %s(k1, v1) VALUES(1, 1)");
-         batchlog.forceBlockingFlush();
-         assertEquals(batchlogSSTables, batchlog.getLiveSSTables().size());
-     }
  }
diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsTest.java
index 831f3ef,24d76d4..380b99a
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsTest.java
@@@ -37,208 -35,18 +35,18 @@@ import org.apache.cassandra.utils.FBUti
  
  import static org.junit.Assert.assertEquals;
  
--/* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670)
++/* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
   * Any changes here check if they apply to the other classes:
   * - ViewComplexUpdatesTest
   * - ViewComplexDeletionsTest
   * - ViewComplexTTLTest
   * - ViewComplexTest
   * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
   */
 -public class ViewComplexDeletionsTest extends ViewComplexTester
 +public class ViewComplexDeletionsTest extends ViewAbstractParameterizedTest
  {
-     // for now, unselected column cannot be fully supported, see CASSANDRA-11500
-     @Ignore
-     @Test
-     public void testPartialDeleteUnselectedColumnWithFlush() throws Throwable
-     {
-         testPartialDeleteUnselectedColumn(true);
-     }
- 
-     // for now, unselected column cannot be fully supported, see CASSANDRA-11500
-     @Ignore
-     @Test
-     public void testPartialDeleteUnselectedColumnWithoutFlush() throws Throwable
-     {
-         testPartialDeleteUnselectedColumn(false);
-     }
- 
-     private void testPartialDeleteUnselectedColumn(boolean flush) throws Throwable
-     {
-         createTable("CREATE TABLE %s (k int, c int, a int, b int, PRIMARY KEY (k, c))");
-         createView("CREATE MATERIALIZED VIEW %s AS " +
-                    "SELECT k,c FROM %s WHERE k IS NOT NULL AND c IS NOT NULL PRIMARY KEY (k,c)");
-         Keyspace ks = Keyspace.open(keyspace());
-         ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
- 
-         updateView("UPDATE %s USING TIMESTAMP 10 SET b=1 WHERE k=1 AND c=1");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, 1));
-         assertRows(executeView("SELECT * FROM %s"), row(1, 1));
-         updateView("DELETE b FROM %s USING TIMESTAMP 11 WHERE k=1 AND c=1");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         assertEmpty(execute("SELECT * from %s"));
-         assertEmpty(executeView("SELECT * FROM %s"));
-         updateView("UPDATE %s USING TIMESTAMP 1 SET a=1 WHERE k=1 AND c=1");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
-         assertRows(execute("SELECT * from %s"), row(1, 1, 1, null));
-         assertRows(executeView("SELECT * FROM %s"), row(1, 1));
- 
-         execute("truncate %s;");
- 
-         // removal generated by unselected column should not shadow PK update with smaller timestamp
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 18 SET a=1 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, 1, null));
-         assertRows(executeView("SELECT * FROM %s"), row(1, 1));
- 
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 20 SET a=null WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"));
-         assertRows(executeView("SELECT * FROM %s"));
- 
-         updateViewWithFlush("INSERT INTO %s(k,c) VALUES(1,1) USING TIMESTAMP 15", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, null));
-         assertRows(executeView("SELECT * FROM %s"), row(1, 1));
-     }
- 
-     @Test
-     public void testPartialDeleteSelectedColumnWithFlush() throws Throwable
-     {
-         testPartialDeleteSelectedColumn(true);
-     }
- 
-     @Test
-     public void testPartialDeleteSelectedColumnWithoutFlush() throws Throwable
-     {
-         testPartialDeleteSelectedColumn(false);
-     }
- 
-     private void testPartialDeleteSelectedColumn(boolean flush) throws Throwable
-     {
-         createTable("CREATE TABLE %s (k int, c int, a int, b int, e int, f int, PRIMARY KEY (k, c))");
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT a, b, c, k FROM %s " +
-                      "WHERE k IS NOT NULL AND c IS NOT NULL PRIMARY KEY (k,c)");
-         Keyspace ks = Keyspace.open(keyspace());
-         ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
- 
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 10 SET b=1 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, 1, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, 1));
- 
-         updateViewWithFlush("DELETE b FROM %s USING TIMESTAMP 11 WHERE k=1 AND c=1", flush);
-         assertEmpty(execute("SELECT * from %s"));
-         assertEmpty(executeView("SELECT * from %s"));
- 
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 1 SET a=1 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, 1, null, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, 1, null));
- 
-         updateViewWithFlush("DELETE a FROM %s USING TIMESTAMP 1 WHERE k=1 AND c=1", flush);
-         assertEmpty(execute("SELECT * from %s"));
-         assertEmpty(executeView("SELECT * from %s"));
- 
-         // view livenessInfo should not be affected by selected column ts or tb
-         updateViewWithFlush("INSERT INTO %s(k,c) VALUES(1,1) USING TIMESTAMP 0", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, null, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, null));
- 
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 12 SET b=1 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, 1, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, 1));
- 
-         updateViewWithFlush("DELETE b FROM %s USING TIMESTAMP 13 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, null, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, null));
- 
-         updateViewWithFlush("DELETE FROM %s USING TIMESTAMP 14 WHERE k=1 AND c=1", flush);
-         assertEmpty(execute("SELECT * from %s"));
-         assertEmpty(executeView("SELECT * from %s"));
- 
-         updateViewWithFlush("INSERT INTO %s(k,c) VALUES(1,1) USING TIMESTAMP 15", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, null, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, null));
- 
-         updateViewWithFlush("UPDATE %s USING TTL 3 SET b=1 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, 1, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, 1));
- 
-         TimeUnit.SECONDS.sleep(4);
- 
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, null, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, null));
- 
-         updateViewWithFlush("DELETE FROM %s USING TIMESTAMP 15 WHERE k=1 AND c=1", flush);
-         assertEmpty(execute("SELECT * from %s"));
-         assertEmpty(executeView("SELECT * from %s"));
- 
-         execute("truncate %s;");
- 
-         // removal generated by unselected column should not shadow selected column with smaller timestamp
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 18 SET e=1 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, null, null, 1, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, null, null));
- 
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 18 SET e=null WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"));
-         assertRows(executeView("SELECT * from %s"));
- 
-         updateViewWithFlush("UPDATE %s USING TIMESTAMP 16 SET a=1 WHERE k=1 AND c=1", flush);
-         assertRows(execute("SELECT * from %s"), row(1, 1, 1, null, null, null));
-         assertRows(executeView("SELECT * from %s"), row(1, 1, 1, null));
-     }
- 
-     @Test
-     public void testRangeDeletionWithFlush() throws Throwable
-     {
-         testRangeDeletion(true);
-     }
- 
-     @Test
-     public void testRangeDeletionWithoutFlush() throws Throwable
-     {
-         testRangeDeletion(false);
-     }
- 
-     private void testRangeDeletion(boolean flush) throws Throwable
-     {
-         // for partition range deletion, need to know that existing row is shadowed instead of not existed.
-         createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a))");
- 
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                      "WHERE a IS NOT NULL AND b IS NOT NULL PRIMARY KEY (a, b)");
- 
-         Keyspace ks = Keyspace.open(keyspace());
-         ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
- 
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?) using timestamp 0", 1, 1, 1, 1);
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"), row(1, 1, 1, 1));
- 
-         // remove view row
-         updateView("UPDATE %s using timestamp 1 set b = null WHERE a=1");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"));
-         // remove base row, no view updated generated.
-         updateView("DELETE FROM %s using timestamp 2 where a=1");
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"));
- 
-         // restor view row with b,c column. d is still tombstone
-         updateView("UPDATE %s using timestamp 3 set b = 1,c = 1 where a=1"); // upsert
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         assertRowsIgnoringOrder(executeView("SELECT * FROM %s"), row(1, 1, 1, null));
-     }
- 
      @Test
      public void testCommutativeRowDeletionFlush() throws Throwable
      {
diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexLivenessLimitTest.java
index 0000000,2be826f..73f6b74
mode 000000,100644..100644
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexLivenessLimitTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexLivenessLimitTest.java
@@@ -1,0 -1,101 +1,100 @@@
+ /*
+  * 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 java.util.Arrays;
+ 
+ import org.junit.Test;
+ 
+ import org.apache.cassandra.db.Keyspace;
+ 
+ import static org.junit.Assert.assertEquals;
+ 
+ /* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
+  * Any changes here check if they apply to the other classes:
+  * - ViewComplexUpdatesTest
+  * - ViewComplexDeletionsTest
+  * - ViewComplexTTLTest
+  * - ViewComplexTest
+  * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
+  */
 -public class ViewComplexLivenessLimitTest extends ViewComplexTester
++public class ViewComplexLivenessLimitTest extends ViewAbstractParameterizedTest
+ {
+     @Test
+     public void testExpiredLivenessLimitWithFlush() throws Throwable
+     {
+         // CASSANDRA-13883
+         testExpiredLivenessLimit(true);
+     }
+ 
+     @Test
+     public void testExpiredLivenessLimitWithoutFlush() throws Throwable
+     {
+         // CASSANDRA-13883
+         testExpiredLivenessLimit(false);
+     }
+ 
+     private void testExpiredLivenessLimit(boolean flush) throws Throwable
+     {
+         createTable("CREATE TABLE %s (k int PRIMARY KEY, a int, b int);");
+ 
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
+         Keyspace ks = Keyspace.open(keyspace());
+ 
 -        String mv1 = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s " +
++        String mv1 = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
+                                 "WHERE k IS NOT NULL AND a IS NOT NULL PRIMARY KEY (k, a)");
 -        String mv2 = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s " +
++        String mv2 = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
+                                 "WHERE k IS NOT NULL AND a IS NOT NULL PRIMARY KEY (a, k)");
+         ks.getColumnFamilyStore(mv1).disableAutoCompaction();
+         ks.getColumnFamilyStore(mv2).disableAutoCompaction();
+ 
+         for (int i = 1; i <= 100; i++)
+             updateView("INSERT INTO %s(k, a, b) VALUES (?, ?, ?);", i, i, i);
+         for (int i = 1; i <= 100; i++)
+         {
+             if (i % 50 == 0)
+                 continue;
+             // create expired liveness
+             updateView("DELETE a FROM %s WHERE k = ?;", i);
+         }
++
+         if (flush)
+         {
+             ks.getColumnFamilyStore(mv1).forceBlockingFlush();
+             ks.getColumnFamilyStore(mv2).forceBlockingFlush();
+         }
+ 
+         for (String view : Arrays.asList(mv1, mv2))
+         {
+             // paging
 -            assertEquals(1, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s limit 1", view), 1).all().size());
 -            assertEquals(2, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s limit 2", view), 1).all().size());
 -            assertEquals(2, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s", view), 1).all().size());
 -            assertRowsNet(version, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s ", view), 1),
++            assertEquals(1, executeNetWithPaging(String.format("SELECT k,a,b FROM %s limit 1", view), 1).all().size());
++            assertEquals(2, executeNetWithPaging(String.format("SELECT k,a,b FROM %s limit 2", view), 1).all().size());
++            assertEquals(2, executeNetWithPaging(String.format("SELECT k,a,b FROM %s", view), 1).all().size());
++            assertRowsNet(executeNetWithPaging(String.format("SELECT k,a,b FROM %s ", view), 1),
+                           row(50, 50, 50),
+                           row(100, 100, 100));
+             // limit
+             assertEquals(1, execute(String.format("SELECT k,a,b FROM %s limit 1", view)).size());
+             assertRowsIgnoringOrder(execute(String.format("SELECT k,a,b FROM %s limit 2", view)),
+                                     row(50, 50, 50),
+                                     row(100, 100, 100));
+         }
+     }
+ }
diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexLivenessTest.java
index 66738ce,1e327e2..cbb2a5f
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexLivenessTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexLivenessTest.java
@@@ -35,30 -33,24 +33,32 @@@ import static org.junit.Assert.assertEq
   * - ViewComplexTTLTest
   * - ViewComplexTest
   * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
   */
 -public class ViewComplexLivenessTest extends ViewComplexTester
 +public class ViewComplexLivenessTest extends ViewAbstractParameterizedTest
  {
      @Test
 -    public void testUnselectedColumnWithExpiredLivenessInfo() throws Throwable
 +    public void testUnselectedColumnWithExpiredLivenessInfoWithFlush() throws Throwable
 +    {
 +        testUnselectedColumnWithExpiredLivenessInfo(true);
 +    }
 +
 +    @Test
 +    public void testUnselectedColumnWithExpiredLivenessInfoWithoutFlush() throws Throwable
 +    {
 +        testUnselectedColumnWithExpiredLivenessInfo(false);
 +    }
 +
 +    private void testUnselectedColumnWithExpiredLivenessInfo(boolean flush) throws Throwable
      {
 -        boolean flush = true;
          createTable("create table %s (k int, c int, a int, b int, PRIMARY KEY(k, c))");
  
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
          Keyspace ks = Keyspace.open(keyspace());
  
 -        String name = createView("create materialized view %s as select k,c,b from %%s " +
 -                                 "where c is not null and k is not null primary key (c, k)");
 -        ks.getColumnFamilyStore(name).disableAutoCompaction();
 +        createView("create materialized view %s as select k,c,b from %s " +
 +                   "where c is not null and k is not null primary key (c, k)");
 +        ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
  
          // sstable-1, Set initial values TS=1
          updateViewWithFlush("UPDATE %s SET a = 1 WHERE k = 1 AND c = 1;", flush);
diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexTTLTest.java
index f8dfa0f,b44c8d0..3a66118
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexTTLTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexTTLTest.java
@@@ -33,8 -33,10 +33,10 @@@ import static org.junit.Assert.assertTr
   * - ViewComplexTTLTest
   * - ViewComplexTest
   * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
   */
 -public class ViewComplexTTLTest extends ViewComplexTester
 +public class ViewComplexTTLTest extends ViewAbstractParameterizedTest
  {
      @Test
      public void testUpdateColumnInViewPKWithTTLWithFlush() throws Throwable
diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexTest.java
index c462ebf,8098dcf..9763564
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexTest.java
@@@ -46,8 -43,10 +43,10 @@@ import static org.junit.Assert.fail
   * - ViewComplexTTLTest
   * - ViewComplexTest
   * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
   */
 -public class ViewComplexTest extends ViewComplexTester
 +public class ViewComplexTest extends ViewAbstractParameterizedTest
  {
      @Test
      public void testNonBaseColumnInViewPkWithFlush() throws Throwable
diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexTombstoneTest.java
index 0000000,3c484ac..bfa03ea
mode 000000,100644..100644
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexTombstoneTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexTombstoneTest.java
@@@ -1,0 -1,116 +1,114 @@@
+ /*
+  * 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 java.util.Arrays;
+ import java.util.Comparator;
+ import java.util.List;
+ import java.util.stream.Collectors;
+ 
+ import org.junit.Test;
+ 
+ import org.apache.cassandra.db.ColumnFamilyStore;
+ import org.apache.cassandra.db.Keyspace;
+ import org.apache.cassandra.db.compaction.CompactionManager;
+ import org.apache.cassandra.io.sstable.format.SSTableReader;
+ import org.apache.cassandra.utils.FBUtilities;
+ 
+ /* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
+  * Any changes here check if they apply to the other classes:
+  * - ViewComplexUpdatesTest
+  * - ViewComplexDeletionsTest
+  * - ViewComplexTTLTest
+  * - ViewComplexTest
+  * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
+  */
 -public class ViewComplexTombstoneTest extends ViewComplexTester
++public class ViewComplexTombstoneTest extends ViewAbstractParameterizedTest
+ {
+     @Test
+     public void testCellTombstoneAndShadowableTombstonesWithFlush() throws Throwable
+     {
+         testCellTombstoneAndShadowableTombstones(true);
+     }
+ 
+     @Test
+     public void testCellTombstoneAndShadowableTombstonesWithoutFlush() throws Throwable
+     {
+         testCellTombstoneAndShadowableTombstones(false);
+     }
+ 
+     private void testCellTombstoneAndShadowableTombstones(boolean flush) throws Throwable
+     {
+         createTable("create table %s (p int primary key, v1 int, v2 int)");
+ 
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
+         Keyspace ks = Keyspace.open(keyspace());
+ 
 -        String mv = createView("create materialized view %s as select * from %%s " +
 -                               "where p is not null and v1 is not null primary key (v1, p)");
 -        ks.getColumnFamilyStore(mv).disableAutoCompaction();
++        createView("create materialized view %s as select * from %s " +
++                   "where p is not null and v1 is not null primary key (v1, p)");
++        ks.getColumnFamilyStore(currentView()).disableAutoCompaction();
+ 
+         // sstable 1, Set initial values TS=1
+         updateView("Insert into %s (p, v1, v2) values (3, 1, 3) using timestamp 1;");
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
 -        assertRowsIgnoringOrder(execute("SELECT v2, WRITETIME(v2) from " + mv + " WHERE v1 = ? AND p = ?", 1, 3), row(3, 1L));
++        assertRowsIgnoringOrder(executeView("SELECT v2, WRITETIME(v2) from %s WHERE v1 = ? AND p = ?", 1, 3), row(3, 1L));
+         // sstable 2
+         updateView("UPdate %s using timestamp 2 set v2 = null where p = 3");
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
 -        assertRowsIgnoringOrder(execute("SELECT v2, WRITETIME(v2) from " + mv + " WHERE v1 = ? AND p = ?", 1, 3),
++        assertRowsIgnoringOrder(executeView("SELECT v2, WRITETIME(v2) from %s WHERE v1 = ? AND p = ?", 1, 3),
+                                 row(null, null));
+         // sstable 3
+         updateView("UPdate %s using timestamp 3 set v1 = 2 where p = 3");
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
 -        assertRowsIgnoringOrder(execute("SELECT v1, p, v2, WRITETIME(v2) from " + mv), row(2, 3, null, null));
++        assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(2, 3, null, null));
+         // sstable 4
+         updateView("UPdate %s using timestamp 4 set v1 = 1 where p = 3");
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
 -        assertRowsIgnoringOrder(execute("SELECT v1, p, v2, WRITETIME(v2) from " + mv), row(1, 3, null, null));
++        assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(1, 3, null, null));
+ 
+         if (flush)
+         {
+             // compact sstable 2 and 3;
 -            ColumnFamilyStore cfs = ks.getColumnFamilyStore(mv);
++            ColumnFamilyStore cfs = ks.getColumnFamilyStore(currentView());
+             List<String> sstables = cfs.getLiveSSTables()
+                                        .stream()
+                                        .sorted(Comparator.comparingInt(s -> s.descriptor.generation))
+                                        .map(SSTableReader::getFilename)
+                                        .collect(Collectors.toList());
+             String dataFiles = String.join(",", Arrays.asList(sstables.get(1), sstables.get(2)));
+             CompactionManager.instance.forceUserDefinedCompaction(dataFiles);
+         }
+         // cell-tombstone in sstable 4 is not compacted away, because the shadowable tombstone is shadowed by new row.
 -        assertRowsIgnoringOrder(execute("SELECT v1, p, v2, WRITETIME(v2) from " + mv), row(1, 3, null, null));
 -        assertRowsIgnoringOrder(execute("SELECT v1, p, v2, WRITETIME(v2) from " + mv + " limit 1"), row(1, 3, null, null));
++        assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s"), row(1, 3, null, null));
++        assertRowsIgnoringOrder(executeView("SELECT v1, p, v2, WRITETIME(v2) from %s limit 1"), row(1, 3, null, null));
+     }
+ }
diff --cc test/unit/org/apache/cassandra/cql3/ViewComplexUpdatesTest.java
index 275296e,c930fa0..d63d3a6
--- a/test/unit/org/apache/cassandra/cql3/ViewComplexUpdatesTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewComplexUpdatesTest.java
@@@ -32,8 -32,10 +32,10 @@@ import org.apache.cassandra.utils.FBUti
   * - ViewComplexTTLTest
   * - ViewComplexTest
   * - ViewComplexLivenessTest
+  * - ...
+  * - ViewComplex*Test
   */
 -public class ViewComplexUpdatesTest extends ViewComplexTester
 +public class ViewComplexUpdatesTest extends ViewAbstractParameterizedTest
  {
      @Test
      public void testUpdateColumnNotInViewWithFlush() throws Throwable
diff --cc test/unit/org/apache/cassandra/cql3/ViewFiltering1Test.java
index 37f755b,0000000..685e679
mode 100644,000000..100644
--- a/test/unit/org/apache/cassandra/cql3/ViewFiltering1Test.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewFiltering1Test.java
@@@ -1,906 -1,0 +1,507 @@@
 +/*
 + * 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 java.util.Arrays;
 +import java.util.List;
 +
 +import org.junit.AfterClass;
 +import org.junit.Assert;
 +import org.junit.BeforeClass;
 +import org.junit.Ignore;
 +import org.junit.Test;
 +
 +import org.apache.cassandra.db.Keyspace;
 +import org.apache.cassandra.exceptions.InvalidRequestException;
 +import org.apache.cassandra.utils.FBUtilities;
 +
- /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670)
++/* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
 + * Any changes here check if they apply to the other classes
 + * - ViewFilteringPKTest
 + * - ViewFilteringClustering1Test
 + * - ViewFilteringClustering2Test
 + * - ViewFilteringTest
++ * - ...
++ * - ViewFiltering*Test
 + */
- public class ViewFilteringTest extends ViewAbstractParameterizedTest
++public class ViewFiltering1Test extends ViewAbstractParameterizedTest
 +{
 +    @BeforeClass
 +    public static void startup()
 +    {
 +        ViewAbstractParameterizedTest.startup();
 +        System.setProperty("cassandra.mv.allow_filtering_nonkey_columns_unsafe", "true");
 +    }
 +
 +    @AfterClass
 +    public static void tearDown()
 +    {
 +        System.setProperty("cassandra.mv.allow_filtering_nonkey_columns_unsafe", "false");
 +    }
 +
 +    // TODO will revise the non-pk filter condition in MV, see CASSANDRA-11500
 +    @Ignore
 +    @Test
 +    public void testViewFilteringWithFlush() throws Throwable
 +    {
 +        testViewFiltering(true);
 +    }
 +
 +    // TODO will revise the non-pk filter condition in MV, see CASSANDRA-11500
 +    @Ignore
 +    @Test
 +    public void testViewFilteringWithoutFlush() throws Throwable
 +    {
 +        testViewFiltering(false);
 +    }
 +
 +    public void testViewFiltering(boolean flush) throws Throwable
 +    {
 +        // CASSANDRA-13547: able to shadow entire view row if base column used in filter condition is modified
 +        createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a))");
 +
 +        String mv1 = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
 +                                "WHERE a IS NOT NULL AND b IS NOT NULL and c = 1  PRIMARY KEY (a, b)");
 +        String mv2 = createView("CREATE MATERIALIZED VIEW %s AS SELECT c, d FROM %s " +
 +                                "WHERE a IS NOT NULL AND b IS NOT NULL and c = 1 and d = 1 PRIMARY KEY (a, b)");
 +        String mv3 = createView("CREATE MATERIALIZED VIEW %s AS SELECT a, b, c, d FROM %%s " +
 +                                "WHERE a IS NOT NULL AND b IS NOT NULL PRIMARY KEY (a, b)");
 +        String mv4 = createView("CREATE MATERIALIZED VIEW %s AS SELECT c FROM %s " +
 +                                "WHERE a IS NOT NULL AND b IS NOT NULL and c = 1 PRIMARY KEY (a, b)");
 +        String mv5 = createView("CREATE MATERIALIZED VIEW %s AS SELECT c FROM %s " +
 +                                "WHERE a IS NOT NULL and d = 1 PRIMARY KEY (a, d)");
 +        String mv6 = createView("CREATE MATERIALIZED VIEW %s AS SELECT c FROM %s " +
 +                                "WHERE a = 1 and d IS NOT NULL PRIMARY KEY (a, d)");
 +
 +        Keyspace ks = Keyspace.open(keyspace());
 +        ks.getColumnFamilyStore(mv1).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv2).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv3).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv4).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv5).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv6).disableAutoCompaction();
 +
 +        execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?) using timestamp 0", 1, 1, 1, 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        // views should be updated.
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, 1));
 +
 +        updateView("UPDATE %s using timestamp 1 set c = ? WHERE a=?", 0, 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowCount(execute("SELECT * FROM " + mv1), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv2), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 0, 1));
 +        assertRowCount(execute("SELECT * FROM " + mv4), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, 0));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, 0));
 +
 +        updateView("UPDATE %s using timestamp 2 set c = ? WHERE a=?", 1, 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        // row should be back in views.
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, 1));
 +
 +        updateView("UPDATE %s using timestamp 3 set d = ? WHERE a=?", 0, 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 1, 1, 0));
 +        assertRowCount(execute("SELECT * FROM " + mv2), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 1, 0));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1, 1));
 +        assertRowCount(execute("SELECT * FROM " + mv5), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 0, 1));
 +
 +        updateView("UPDATE %s using timestamp 4 set c = ? WHERE a=?", 0, 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowCount(execute("SELECT * FROM " + mv1), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv2), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 0, 0));
 +        assertRowCount(execute("SELECT * FROM " + mv4), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv5), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 0, 0));
 +
 +        updateView("UPDATE %s using timestamp 5 set d = ? WHERE a=?", 1, 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        // should not update as c=0
 +        assertRowCount(execute("SELECT * FROM " + mv1), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv2), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 0, 1));
 +        assertRowCount(execute("SELECT * FROM " + mv4), 0);
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, 0));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, 0));
 +
 +        updateView("UPDATE %s using timestamp 6 set c = ? WHERE a=?", 1, 1);
 +
 +        // row should be back in views.
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, 1));
 +
 +        updateView("UPDATE %s using timestamp 7 set b = ? WHERE a=?", 2, 1);
 +        if (flush)
 +        {
 +            FBUtilities.waitOnFutures(ks.flush());
 +            for (String view : getViews())
 +                ks.getColumnFamilyStore(view).forceMajorCompaction();
 +        }
 +        // row should be back in views.
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 2, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2), row(1, 2, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 2, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 2, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, 1));
 +
 +        updateView("DELETE b, c FROM %s using timestamp 6 WHERE a=?", 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT * FROM %s"), row(1, 2, null, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 2, null, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, null));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, null));
 +
 +        updateView("DELETE FROM %s using timestamp 8 where a=?", 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowCount(execute("SELECT * FROM " + mv1), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv2), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv3), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv4), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv5), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv6), 0);
 +
 +        updateView("UPDATE %s using timestamp 9 set b = ?,c = ? where a=?", 1, 1, 1); // upsert
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 1, 1, null));
 +        assertRows(execute("SELECT * FROM " + mv2));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 1, null));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1, 1));
 +        assertRows(execute("SELECT * FROM " + mv5));
 +        assertRows(execute("SELECT * FROM " + mv6));
 +
 +        updateView("DELETE FROM %s using timestamp 10 where a=?", 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowCount(execute("SELECT * FROM " + mv1), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv2), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv3), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv4), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv5), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv6), 0);
 +
 +        execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?) using timestamp 11", 1, 1, 1, 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        // row should be back in views.
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv5), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv6), row(1, 1, 1));
 +
 +        updateView("DELETE FROM %s using timestamp 12 where a=?", 1);
 +        if (flush)
 +            FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowCount(execute("SELECT * FROM " + mv1), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv2), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv3), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv4), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv5), 0);
 +        assertRowCount(execute("SELECT * FROM " + mv6), 0);
 +
 +        dropView(mv1);
 +        dropView(mv2);
 +        dropView(mv3);
 +        dropView(mv4);
 +        dropView(mv5);
 +        dropView(mv6);
 +        dropTable("DROP TABLE %s");
 +    }
 +
 +    // TODO will revise the non-pk filter condition in MV, see CASSANDRA-11500
 +    @Ignore
 +    @Test
 +    public void testMVFilteringWithComplexColumn() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (a int, b int, c int, l list<int>, s set<int>, m map<int,int>, PRIMARY KEY (a, b))");
 +
 +        String mv1 = createView("CREATE MATERIALIZED VIEW %s AS SELECT a,b,c FROM %%s " +
 +                                "WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND l contains (1) " +
 +                                "AND s contains (1) AND m contains key (1) " +
 +                                "PRIMARY KEY (a, b, c)");
 +        String mv2 = createView("CREATE MATERIALIZED VIEW %s AS SELECT a,b FROM %%s " +
 +                                "WHERE a IS NOT NULL and b IS NOT NULL AND l contains (1) " +
 +                                "PRIMARY KEY (a, b)");
 +        String mv3 = createView("CREATE MATERIALIZED VIEW %s AS SELECT a,b FROM %%s " +
 +                                "WHERE a IS NOT NULL AND b IS NOT NULL AND s contains (1) " +
 +                                "PRIMARY KEY (a, b)");
 +        String mv4 = createView("CREATE MATERIALIZED VIEW %s AS SELECT a,b FROM %%s " +
 +                                "WHERE a IS NOT NULL AND b IS NOT NULL AND m contains key (1) " +
 +                                "PRIMARY KEY (a, b)");
 +
 +        // not able to drop base column filtered in view
 +        assertInvalidMessage("Cannot drop column l, depended on by materialized views", "ALTER TABLE %s DROP l");
 +        assertInvalidMessage("Cannot drop column s, depended on by materialized views", "ALTER TABLE %S DROP s");
 +        assertInvalidMessage("Cannot drop column m, depended on by materialized views", "ALTER TABLE %s DROP m");
 +
 +        Keyspace ks = Keyspace.open(keyspace());
 +        ks.getColumnFamilyStore(mv1).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv2).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv3).disableAutoCompaction();
 +        ks.getColumnFamilyStore(mv4).disableAutoCompaction();
 +
 +        execute("INSERT INTO %s (a, b, c, l, s, m) VALUES (?, ?, ?, ?, ?, ?) ",
 +                1,
 +                1,
 +                1,
 +                list(1, 1, 2),
 +                set(1, 2),
 +                map(1, 1, 2, 2));
 +        FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2), row(1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1));
 +
 +        execute("UPDATE %s SET l=l-[1] WHERE a = 1 AND b = 1");
 +        FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1));
 +
 +        execute("UPDATE %s SET s=s-{2}, m=m-{2} WHERE a = 1 AND b = 1");
 +        FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT a,b,c FROM %s"), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4), row(1, 1));
 +
 +        execute("UPDATE %s SET  m=m-{1} WHERE a = 1 AND b = 1");
 +        FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT a,b,c FROM %s"), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4));
 +
 +        // filter conditions result not changed
 +        execute("UPDATE %s SET  l=l+[2], s=s-{0}, m=m+{3:3} WHERE a = 1 AND b = 1");
 +        FBUtilities.waitOnFutures(ks.flush());
 +
 +        assertRowsIgnoringOrder(execute("SELECT a,b,c FROM %s"), row(1, 1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv2));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv3), row(1, 1));
 +        assertRowsIgnoringOrder(execute("SELECT * FROM " + mv4));
 +    }
 +
 +    @Test
 +    public void testMVCreationSelectRestrictions() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY((a, b), c, d))");
 +
 +        // IS NOT NULL is required on all PK statements that are not otherwise restricted
 +        List<String> badStatements = Arrays.asList(
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE b IS NOT NULL AND c IS NOT NULL AND d is NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a IS NOT NULL AND c IS NOT NULL AND d is NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a IS NOT NULL AND b IS NOT NULL AND d is NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a IS NOT NULL AND b IS NOT NULL AND c is NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = ? AND b IS NOT NULL AND c is NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = blobAsInt(?) AND b IS NOT NULL AND c is NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s PRIMARY KEY (a, b, c, d)"
 +        );
 +
 +        for (String badStatement : badStatements)
 +        {
 +            try
 +            {
 +                createView(badStatement);
 +                Assert.fail("Create MV statement should have failed due to missing IS NOT NULL restriction: " + badStatement);
 +            }
 +            catch (RuntimeException e)
 +            {
 +                Assert.assertSame(InvalidRequestException.class, e.getCause().getClass());
 +            }
 +        }
 +
 +        List<String> goodStatements = Arrays.asList(
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND c IS NOT NULL AND d is NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a IS NOT NULL AND b IS NOT NULL AND c = 1 AND d IS NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a IS NOT NULL AND b IS NOT NULL AND c = 1 AND d = 1 PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND c = 1 AND d = 1 PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND c > 1 AND d IS NOT NULL PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND c = 1 AND d IN (1, 2, 3) PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND (c, d) = (1, 1) PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND (c, d) > (1, 1) PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND (c, d) IN ((1, 1), (2, 2)) PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = (int) 1 AND b = 1 AND c = 1 AND d = 1 PRIMARY KEY ((a, b), c, d)",
 +        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = blobAsInt(intAsBlob(1)) AND b = 1 AND c = 1 AND d = 1 PRIMARY KEY ((a, b), c, d)"
 +        );
 +
 +        for (int i = 0; i < goodStatements.size(); i++)
 +        {
 +            String mv;
 +            try
 +            {
 +                mv = createView(goodStatements.get(i));
 +            }
 +            catch (Exception e)
 +            {
 +                throw new RuntimeException("MV creation failed: " + goodStatements.get(i), e);
 +            }
 +
 +            try
 +            {
 +                executeNet("ALTER MATERIALIZED VIEW " + mv + " WITH compaction = { 'class' : 'LeveledCompactionStrategy' }");
 +            }
 +            catch (Exception e)
 +            {
 +                throw new RuntimeException("MV alter failed: " + goodStatements.get(i), e);
 +            }
 +        }
 +    }
 +
 +    @Test
 +    public void testCaseSensitivity() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (\"theKey\" int, \"theClustering\" int, \"the\"\"Value\" int, PRIMARY KEY (\"theKey\", \"theClustering\"))");
 +
 +        execute("INSERT INTO %s (\"theKey\", \"theClustering\", \"the\"\"Value\") VALUES (?, ?, ?)", 0, 0, 0);
 +        execute("INSERT INTO %s (\"theKey\", \"theClustering\", \"the\"\"Value\") VALUES (?, ?, ?)", 0, 1, 0);
 +        execute("INSERT INTO %s (\"theKey\", \"theClustering\", \"the\"\"Value\") VALUES (?, ?, ?)", 1, 0, 0);
 +        execute("INSERT INTO %s (\"theKey\", \"theClustering\", \"the\"\"Value\") VALUES (?, ?, ?)", 1, 1, 0);
 +
 +        String mv1 = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
 +                                "WHERE \"theKey\" = 1 AND \"theClustering\" = 1 AND \"the\"\"Value\" IS NOT NULL " +
 +                                "PRIMARY KEY (\"theKey\", \"theClustering\")");
 +
 +        String mv2 = createView("CREATE MATERIALIZED VIEW %s AS SELECT \"theKey\", \"theClustering\", \"the\"\"Value\" FROM %s " +
 +                                "WHERE \"theKey\" = 1 AND \"theClustering\" = 1 AND \"the\"\"Value\" IS NOT NULL " +
 +                                "PRIMARY KEY (\"theKey\", \"theClustering\")");
 +
 +        for (String mvname : Arrays.asList(mv1, mv2))
 +        {
 +            assertRowsIgnoringOrder(execute("SELECT \"theKey\", \"theClustering\", \"the\"\"Value\" FROM " + mvname),
 +                                    row(1, 1, 0));
 +        }
 +
 +        executeNet("ALTER TABLE %s RENAME \"theClustering\" TO \"Col\"");
 +
 +        for (String mvname : Arrays.asList(mv1, mv2))
 +        {
 +            assertRowsIgnoringOrder(execute("SELECT \"theKey\", \"Col\", \"the\"\"Value\" FROM " + mvname),
 +                                    row(1, 1, 0)
 +            );
 +        }
 +    }
 +
 +    @Test
 +    public void testFilterWithFunction() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))");
 +
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 0, 0, 0);
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 0, 1, 1);
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 1, 0, 2);
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 1, 1, 3);
 +
 +        createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
 +                   "WHERE a = blobAsInt(intAsBlob(1)) AND b IS NOT NULL " +
 +                   "PRIMARY KEY (a, b)");
 +
 +        assertRows(executeView("SELECT a, b, c FROM %s"),
 +                   row(1, 0, 2),
 +                   row(1, 1, 3)
 +        );
 +
 +        executeNet("ALTER TABLE %s RENAME a TO foo");
 +
 +        assertRows(executeView("SELECT foo, b, c FROM %s"),
 +                   row(1, 0, 2),
 +                   row(1, 1, 3)
 +        );
 +    }
 +
 +    @Test
 +    public void testFilterWithTypecast() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))");
 +
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 0, 0, 0);
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 0, 1, 1);
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 1, 0, 2);
 +        execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 1, 1, 3);
 +
 +        createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
 +                   "WHERE a = (int) 1 AND b IS NOT NULL " +
 +                   "PRIMARY KEY (a, b)");
 +
 +        assertRows(executeView("SELECT a, b, c FROM %s"),
 +                   row(1, 0, 2),
 +                   row(1, 1, 3)
 +        );
 +
 +        executeNet("ALTER TABLE %s RENAME a TO foo");
 +
 +        assertRows(executeView("SELECT foo, b, c FROM %s"),
 +                   row(1, 0, 2),
 +                   row(1, 1, 3)
 +        );
 +    }
- 
-     @Test
-     public void testAllTypes() throws Throwable
-     {
-         String myType = createType("CREATE TYPE %s (a int, b uuid, c set<text>)");
-         String columnNames = "asciival, " +
-                              "bigintval, " +
-                              "blobval, " +
-                              "booleanval, " +
-                              "dateval, " +
-                              "decimalval, " +
-                              "doubleval, " +
-                              "floatval, " +
-                              "inetval, " +
-                              "intval, " +
-                              "textval, " +
-                              "timeval, " +
-                              "timestampval, " +
-                              "timeuuidval, " +
-                              "uuidval," +
-                              "varcharval, " +
-                              "varintval, " +
-                              "frozenlistval, " +
-                              "frozensetval, " +
-                              "frozenmapval, " +
-                              "tupleval, " +
-                              "udtval";
- 
-         createTable(
-         "CREATE TABLE %s (" +
-         "asciival ascii, " +
-         "bigintval bigint, " +
-         "blobval blob, " +
-         "booleanval boolean, " +
-         "dateval date, " +
-         "decimalval decimal, " +
-         "doubleval double, " +
-         "floatval float, " +
-         "inetval inet, " +
-         "intval int, " +
-         "textval text, " +
-         "timeval time, " +
-         "timestampval timestamp, " +
-         "timeuuidval timeuuid, " +
-         "uuidval uuid," +
-         "varcharval varchar, " +
-         "varintval varint, " +
-         "frozenlistval frozen<list<int>>, " +
-         "frozensetval frozen<set<uuid>>, " +
-         "frozenmapval frozen<map<ascii, int>>," +
-         "tupleval frozen<tuple<int, ascii, uuid>>," +
-         "udtval frozen<" + myType + ">, " +
-         "PRIMARY KEY (" + columnNames + "))");
- 
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE " +
-                    "asciival = 'abc' AND " +
-                    "bigintval = 123 AND " +
-                    "blobval = 0xfeed AND " +
-                    "booleanval = true AND " +
-                    "dateval = '1987-03-23' AND " +
-                    "decimalval = 123.123 AND " +
-                    "doubleval = 123.123 AND " +
-                    "floatval = 123.123 AND " +
-                    "inetval = '127.0.0.1' AND " +
-                    "intval = 123 AND " +
-                    "textval = 'abc' AND " +
-                    "timeval = '07:35:07.000111222' AND " +
-                    "timestampval = 123123123 AND " +
-                    "timeuuidval = 6BDDC89A-5644-11E4-97FC-56847AFE9799 AND " +
-                    "uuidval = 6BDDC89A-5644-11E4-97FC-56847AFE9799 AND " +
-                    "varcharval = 'abc' AND " +
-                    "varintval = 123123123 AND " +
-                    "frozenlistval = [1, 2, 3] AND " +
-                    "frozensetval = {6BDDC89A-5644-11E4-97FC-56847AFE9799} AND " +
-                    "frozenmapval = {'a': 1, 'b': 2} AND " +
-                    "tupleval = (1, 'foobar', 6BDDC89A-5644-11E4-97FC-56847AFE9799) AND " +
-                    "udtval = {a: 1, b: 6BDDC89A-5644-11E4-97FC-56847AFE9799, c: {'foo', 'bar'}} " +
-                    "PRIMARY KEY (" + columnNames + ")");
- 
-         execute("INSERT INTO %s (" + columnNames + ") VALUES (" +
-                 "'abc'," +
-                 "123," +
-                 "0xfeed," +
-                 "true," +
-                 "'1987-03-23'," +
-                 "123.123," +
-                 "123.123," +
-                 "123.123," +
-                 "'127.0.0.1'," +
-                 "123," +
-                 "'abc'," +
-                 "'07:35:07.000111222'," +
-                 "123123123," +
-                 "6BDDC89A-5644-11E4-97FC-56847AFE9799," +
-                 "6BDDC89A-5644-11E4-97FC-56847AFE9799," +
-                 "'abc'," +
-                 "123123123," +
-                 "[1, 2, 3]," +
-                 "{6BDDC89A-5644-11E4-97FC-56847AFE9799}," +
-                 "{'a': 1, 'b': 2}," +
-                 "(1, 'foobar', 6BDDC89A-5644-11E4-97FC-56847AFE9799)," +
-                 "{a: 1, b: 6BDDC89A-5644-11E4-97FC-56847AFE9799, c: {'foo', 'bar'}})");
- 
-         assert !executeView("SELECT * FROM %s").isEmpty();
- 
-         executeNet("ALTER TABLE %s RENAME inetval TO foo");
-         assert !executeView("SELECT * FROM %s").isEmpty();
-     }
- 
-     @Test
-     public void testMVCreationWithNonPrimaryRestrictions()
-     {
-         createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b))");
- 
-         try
-         {
-             String mv = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                                    "WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND d = 1 " +
-                                    "PRIMARY KEY (a, b, c)");
-             dropView(mv);
-         }
-         catch (Exception e)
-         {
-             throw new RuntimeException("MV creation with non primary column restrictions failed.", e);
-         }
- 
-         dropTable("DROP TABLE %s");
-     }
- 
-     @Test
-     public void testNonPrimaryRestrictions() throws Throwable
-     {
-         createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b))");
- 
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0);
- 
-         // only accept rows where c = 1
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                    "WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND c = 1 " +
-                    "PRIMARY KEY (a, b, c)");
- 
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0),
-                                 row(1, 0, 1, 0),
-                                 row(1, 1, 1, 0)
-         );
- 
-         // insert new rows that do not match the filter
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, 2, 0);
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0),
-                                 row(1, 0, 1, 0),
-                                 row(1, 1, 1, 0)
-         );
- 
-         // insert new row that does match the filter
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 1, 0);
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0),
-                                 row(1, 0, 1, 0),
-                                 row(1, 1, 1, 0),
-                                 row(1, 2, 1, 0)
-         );
- 
-         // update rows that don't match the filter
-         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ?", 2, 2, 0);
-         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ?", 1, 2, 1);
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0),
-                                 row(1, 0, 1, 0),
-                                 row(1, 1, 1, 0),
-                                 row(1, 2, 1, 0)
-         );
- 
-         // update a row that does match the filter
-         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ?", 1, 1, 0);
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0),
-                                 row(1, 0, 1, 1),
-                                 row(1, 1, 1, 0),
-                                 row(1, 2, 1, 0)
-         );
- 
-         // delete rows that don't match the filter
-         execute("DELETE FROM %s WHERE a = ? AND b = ?", 2, 0);
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0),
-                                 row(1, 0, 1, 1),
-                                 row(1, 1, 1, 0),
-                                 row(1, 2, 1, 0)
-         );
- 
-         // delete a row that does match the filter
-         execute("DELETE FROM %s WHERE a = ? AND b = ?", 1, 2);
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0),
-                                 row(1, 0, 1, 1),
-                                 row(1, 1, 1, 0)
-         );
- 
-         // delete a partition that matches the filter
-         execute("DELETE FROM %s WHERE a = ?", 1);
-         assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                 row(0, 0, 1, 0),
-                                 row(0, 1, 1, 0)
-         );
- 
-         dropView();
-         dropTable("DROP TABLE %s");
-     }
- 
-     @Test
-     public void complexRestrictedTimestampUpdateTestWithFlush() throws Throwable
-     {
-         complexRestrictedTimestampUpdateTest(true);
-     }
- 
-     @Test
-     public void complexRestrictedTimestampUpdateTestWithoutFlush() throws Throwable
-     {
-         complexRestrictedTimestampUpdateTest(false);
-     }
- 
-     public void complexRestrictedTimestampUpdateTest(boolean flush) throws Throwable
-     {
-         createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b))");
-         Keyspace ks = Keyspace.open(keyspace());
- 
-         String mv = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                                "WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND c = 1 " +
-                                "PRIMARY KEY (c, a, b)");
-         ks.getColumnFamilyStore(mv).disableAutoCompaction();
- 
-         //Set initial values TS=0, matching the restriction and verify view
-         executeNet("INSERT INTO %s (a, b, c, d) VALUES (0, 0, 1, 0) USING TIMESTAMP 0");
-         assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0));
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         //update c's timestamp TS=2
-         executeNet("UPDATE %s USING TIMESTAMP 2 SET c = ? WHERE a = ? and b = ? ", 1, 0, 0);
-         assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0));
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         //change c's value and TS=3, tombstones c=1 and adds c=0 record
-         executeNet("UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE a = ? and b = ? ", 0, 0, 0);
-         assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 0, 0, 0));
- 
-         if (flush)
-         {
-             ks.getColumnFamilyStore(mv).forceMajorCompaction();
-             FBUtilities.waitOnFutures(ks.flush());
-         }
- 
-         //change c's value back to 1 with TS=4, check we can see d
-         executeNet("UPDATE %s USING TIMESTAMP 4 SET c = ? WHERE a = ? and b = ? ", 1, 0, 0);
-         if (flush)
-         {
-             ks.getColumnFamilyStore(mv).forceMajorCompaction();
-             FBUtilities.waitOnFutures(ks.flush());
-         }
- 
-         assertRows(executeView("SELECT d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0, null));
- 
-         //Add e value @ TS=1
-         executeNet("UPDATE %s USING TIMESTAMP 1 SET e = ? WHERE a = ? and b = ? ", 1, 0, 0);
-         assertRows(executeView("SELECT d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0, 1));
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         //Change d value @ TS=2
-         executeNet("UPDATE %s USING TIMESTAMP 2 SET d = ? WHERE a = ? and b = ? ", 2, 0, 0);
-         assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(2));
- 
-         if (flush)
-             FBUtilities.waitOnFutures(ks.flush());
- 
-         //Change d value @ TS=3
-         executeNet("UPDATE %s USING TIMESTAMP 3 SET d = ? WHERE a = ? and b = ? ", 1, 0, 0);
-         assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(1));
- 
-         //Tombstone c
-         executeNet("DELETE FROM %s WHERE a = ? and b = ?", 0, 0);
-         assertRowsIgnoringOrder(executeView("SELECT d FROM %s"));
-         assertRows(executeView("SELECT d FROM %s"));
- 
-         //Add back without D
-         executeNet("INSERT INTO %s (a, b, c) VALUES (0, 0, 1)");
- 
-         //Make sure D doesn't pop back in.
-         assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row((Object) null));
- 
-         //New partition
-         // insert a row with timestamp 0
-         executeNet("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?) USING TIMESTAMP 0", 1, 0, 1, 0, 0);
- 
-         // overwrite pk and e with timestamp 1, but don't overwrite d
-         executeNet("INSERT INTO %s (a, b, c, e) VALUES (?, ?, ?, ?) USING TIMESTAMP 1", 1, 0, 1, 0);
- 
-         // delete with timestamp 0 (which should only delete d)
-         executeNet("DELETE FROM %s USING TIMESTAMP 0 WHERE a = ? AND b = ?", 1, 0);
-         assertRows(executeView("SELECT a, b, c, d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 1, 0),
-                    row(1, 0, 1, null, 0)
-         );
- 
-         executeNet("UPDATE %s USING TIMESTAMP 2 SET c = ? WHERE a = ? AND b = ?", 1, 1, 1);
-         executeNet("UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE a = ? AND b = ?", 1, 1, 0);
-         assertRows(executeView("SELECT a, b, c, d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 1, 0),
-                    row(1, 0, 1, null, 0)
-         );
- 
-         executeNet("UPDATE %s USING TIMESTAMP 3 SET d = ? WHERE a = ? AND b = ?", 0, 1, 0);
-         assertRows(executeView("SELECT a, b, c, d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 1, 0),
-                    row(1, 0, 1, 0, 0)
-         );
-     }
- 
-     @Test
-     public void testRestrictedRegularColumnTimestampUpdates() throws Throwable
-     {
-         // Regression test for CASSANDRA-10910
- 
-         createTable("CREATE TABLE %s (" +
-                     "k int PRIMARY KEY, " +
-                     "c int, " +
-                     "val int)");
- 
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                    "WHERE k IS NOT NULL AND c IS NOT NULL AND c = 1 " +
-                    "PRIMARY KEY (k,c)");
- 
-         updateView("UPDATE %s SET c = ?, val = ? WHERE k = ?", 0, 0, 0);
-         updateView("UPDATE %s SET val = ? WHERE k = ?", 1, 0);
-         updateView("UPDATE %s SET c = ? WHERE k = ?", 1, 0);
-         assertRows(executeView("SELECT c, k, val FROM %s"), row(1, 0, 1));
- 
-         updateView("TRUNCATE %s");
- 
-         updateView("UPDATE %s USING TIMESTAMP 1 SET c = ?, val = ? WHERE k = ?", 0, 0, 0);
-         updateView("UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE k = ?", 1, 0);
-         updateView("UPDATE %s USING TIMESTAMP 2 SET val = ? WHERE k = ?", 1, 0);
-         updateView("UPDATE %s USING TIMESTAMP 4 SET c = ? WHERE k = ?", 1, 0);
-         updateView("UPDATE %s USING TIMESTAMP 3 SET val = ? WHERE k = ?", 2, 0);
-         assertRows(executeView("SELECT c, k, val FROM %s"), row(1, 0, 2));
-     }
- 
-     @Test
-     public void testOldTimestampsWithRestrictions() throws Throwable
-     {
-         createTable("CREATE TABLE %s (" +
-                     "k int, " +
-                     "c int, " +
-                     "val text, " + "" +
-                     "PRIMARY KEY(k, c))");
- 
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                    "WHERE val IS NOT NULL AND k IS NOT NULL AND c IS NOT NULL AND val = 'baz' " +
-                    "PRIMARY KEY (val,k,c)");
- 
-         for (int i = 0; i < 100; i++)
-             updateView("INSERT into %s (k,c,val)VALUES(?,?,?)", 0, i % 2, "baz");
- 
-         Keyspace.open(keyspace()).getColumnFamilyStore(currentTable()).forceBlockingFlush();
- 
-         Assert.assertEquals(2, execute("select * from %s").size());
-         Assert.assertEquals(2, executeView("select * from %s").size());
- 
-         assertRows(execute("SELECT val from %s where k = 0 and c = 0"), row("baz"));
-         assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "baz"), row(0), row(1));
- 
-         //Make sure an old TS does nothing
-         updateView("UPDATE %s USING TIMESTAMP 100 SET val = ? where k = ? AND c = ?", "bar", 0, 1);
-         assertRows(execute("SELECT val from %s where k = 0 and c = 1"), row("baz"));
-         assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "baz"), row(0), row(1));
-         assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "bar"));
- 
-         //Latest TS
-         updateView("UPDATE %s SET val = ? where k = ? AND c = ?", "bar", 0, 1);
-         assertRows(execute("SELECT val from %s where k = 0 and c = 1"), row("bar"));
-         assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "bar"));
-         assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "baz"), row(0));
-     }
 +}
diff --cc test/unit/org/apache/cassandra/cql3/ViewFiltering2Test.java
index 0000000,2eb0eca..8ce1bd5
mode 000000,100644..100644
--- a/test/unit/org/apache/cassandra/cql3/ViewFiltering2Test.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewFiltering2Test.java
@@@ -1,0 -1,452 +1,452 @@@
+ /*
+  * 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.AfterClass;
+ import org.junit.Assert;
++import org.junit.BeforeClass;
+ import org.junit.Test;
 -import org.junit.runner.RunWith;
 -import org.junit.runners.Parameterized;
+ 
+ import org.apache.cassandra.db.Keyspace;
 -import org.apache.cassandra.db.SystemKeyspace;
+ import org.apache.cassandra.utils.FBUtilities;
+ 
+ /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
+  * Any changes here check if they apply to the other classes
+  * - ViewFilteringPKTest
+  * - ViewFilteringClustering1Test
+  * - ViewFilteringClustering2Test
+  * - ViewFilteringTest
+  * - ...
+  * - ViewFiltering*Test
+  */
 -@RunWith(Parameterized.class)
 -public class ViewFiltering2Test extends ViewFilteringTester
++public class ViewFiltering2Test extends ViewAbstractParameterizedTest
+ {
++    @BeforeClass
++    public static void startup()
++    {
++        ViewFiltering1Test.startup();
++    }
++
++    @AfterClass
++    public static void tearDown()
++    {
++        ViewFiltering1Test.tearDown();
++    }
++
+     @Test
+     public void testAllTypes() throws Throwable
+     {
+         String myType = createType("CREATE TYPE %s (a int, b uuid, c set<text>)");
+         String columnNames = "asciival, " +
+                              "bigintval, " +
+                              "blobval, " +
+                              "booleanval, " +
+                              "dateval, " +
+                              "decimalval, " +
+                              "doubleval, " +
+                              "floatval, " +
+                              "inetval, " +
+                              "intval, " +
+                              "textval, " +
+                              "timeval, " +
+                              "timestampval, " +
+                              "timeuuidval, " +
+                              "uuidval," +
+                              "varcharval, " +
+                              "varintval, " +
+                              "frozenlistval, " +
+                              "frozensetval, " +
+                              "frozenmapval, " +
+                              "tupleval, " +
+                              "udtval";
+ 
+         createTable(
+         "CREATE TABLE %s (" +
+         "asciival ascii, " +
+         "bigintval bigint, " +
+         "blobval blob, " +
+         "booleanval boolean, " +
+         "dateval date, " +
+         "decimalval decimal, " +
+         "doubleval double, " +
+         "floatval float, " +
+         "inetval inet, " +
+         "intval int, " +
+         "textval text, " +
+         "timeval time, " +
+         "timestampval timestamp, " +
+         "timeuuidval timeuuid, " +
+         "uuidval uuid," +
+         "varcharval varchar, " +
+         "varintval varint, " +
+         "frozenlistval frozen<list<int>>, " +
+         "frozensetval frozen<set<uuid>>, " +
+         "frozenmapval frozen<map<ascii, int>>," +
+         "tupleval frozen<tuple<int, ascii, uuid>>," +
+         "udtval frozen<" + myType + ">, " +
+         "PRIMARY KEY (" + columnNames + "))");
+ 
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
 -
 -        createView(
 -        "mv_test",
 -        "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE " +
 -        "asciival = 'abc' AND " +
 -        "bigintval = 123 AND " +
 -        "blobval = 0xfeed AND " +
 -        "booleanval = true AND " +
 -        "dateval = '1987-03-23' AND " +
 -        "decimalval = 123.123 AND " +
 -        "doubleval = 123.123 AND " +
 -        "floatval = 123.123 AND " +
 -        "inetval = '127.0.0.1' AND " +
 -        "intval = 123 AND " +
 -        "textval = 'abc' AND " +
 -        "timeval = '07:35:07.000111222' AND " +
 -        "timestampval = 123123123 AND " +
 -        "timeuuidval = 6BDDC89A-5644-11E4-97FC-56847AFE9799 AND " +
 -        "uuidval = 6BDDC89A-5644-11E4-97FC-56847AFE9799 AND " +
 -        "varcharval = 'abc' AND " +
 -        "varintval = 123123123 AND " +
 -        "frozenlistval = [1, 2, 3] AND " +
 -        "frozensetval = {6BDDC89A-5644-11E4-97FC-56847AFE9799} AND " +
 -        "frozenmapval = {'a': 1, 'b': 2} AND " +
 -        "tupleval = (1, 'foobar', 6BDDC89A-5644-11E4-97FC-56847AFE9799) AND " +
 -        "udtval = {a: 1, b: 6BDDC89A-5644-11E4-97FC-56847AFE9799, c: {'foo', 'bar'}} " +
 -        "PRIMARY KEY (" + columnNames + ")");
++        createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE " +
++                   "asciival = 'abc' AND " +
++                   "bigintval = 123 AND " +
++                   "blobval = 0xfeed AND " +
++                   "booleanval = true AND " +
++                   "dateval = '1987-03-23' AND " +
++                   "decimalval = 123.123 AND " +
++                   "doubleval = 123.123 AND " +
++                   "floatval = 123.123 AND " +
++                   "inetval = '127.0.0.1' AND " +
++                   "intval = 123 AND " +
++                   "textval = 'abc' AND " +
++                   "timeval = '07:35:07.000111222' AND " +
++                   "timestampval = 123123123 AND " +
++                   "timeuuidval = 6BDDC89A-5644-11E4-97FC-56847AFE9799 AND " +
++                   "uuidval = 6BDDC89A-5644-11E4-97FC-56847AFE9799 AND " +
++                   "varcharval = 'abc' AND " +
++                   "varintval = 123123123 AND " +
++                   "frozenlistval = [1, 2, 3] AND " +
++                   "frozensetval = {6BDDC89A-5644-11E4-97FC-56847AFE9799} AND " +
++                   "frozenmapval = {'a': 1, 'b': 2} AND " +
++                   "tupleval = (1, 'foobar', 6BDDC89A-5644-11E4-97FC-56847AFE9799) AND " +
++                   "udtval = {a: 1, b: 6BDDC89A-5644-11E4-97FC-56847AFE9799, c: {'foo', 'bar'}} " +
++                   "PRIMARY KEY (" + columnNames + ")");
+ 
+         execute("INSERT INTO %s (" + columnNames + ") VALUES (" +
+                 "'abc'," +
+                 "123," +
+                 "0xfeed," +
+                 "true," +
+                 "'1987-03-23'," +
+                 "123.123," +
+                 "123.123," +
+                 "123.123," +
+                 "'127.0.0.1'," +
+                 "123," +
+                 "'abc'," +
+                 "'07:35:07.000111222'," +
+                 "123123123," +
+                 "6BDDC89A-5644-11E4-97FC-56847AFE9799," +
+                 "6BDDC89A-5644-11E4-97FC-56847AFE9799," +
+                 "'abc'," +
+                 "123123123," +
+                 "[1, 2, 3]," +
+                 "{6BDDC89A-5644-11E4-97FC-56847AFE9799}," +
+                 "{'a': 1, 'b': 2}," +
+                 "(1, 'foobar', 6BDDC89A-5644-11E4-97FC-56847AFE9799)," +
+                 "{a: 1, b: 6BDDC89A-5644-11E4-97FC-56847AFE9799, c: {'foo', 'bar'}})");
+ 
 -        assert !execute("SELECT * FROM mv_test").isEmpty();
++        assert !executeView("SELECT * FROM %s").isEmpty();
+ 
 -        executeNet(version, "ALTER TABLE %s RENAME inetval TO foo");
 -        assert !execute("SELECT * FROM mv_test").isEmpty();
++        executeNet("ALTER TABLE %s RENAME inetval TO foo");
++        assert !executeView("SELECT * FROM %s").isEmpty();
+     }
+ 
+     @Test
 -    public void testMVCreationWithNonPrimaryRestrictions() throws Throwable
++    public void testMVCreationWithNonPrimaryRestrictions()
+     {
+         createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b))");
+ 
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
 -
 -        try {
 -            createView("mv_test", "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND d = 1 PRIMARY KEY (a, b, c)");
 -            dropView("mv_test");
 -        } catch(Exception e) {
++        try
++        {
++            String mv = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
++                                   "WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND d = 1 " +
++                                   "PRIMARY KEY (a, b, c)");
++            dropView(mv);
++        }
++        catch (Exception e)
++        {
+             throw new RuntimeException("MV creation with non primary column restrictions failed.", e);
+         }
+ 
+         dropTable("DROP TABLE %s");
+     }
+ 
+     @Test
+     public void testNonPrimaryRestrictions() throws Throwable
+     {
+         createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b))");
+ 
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
 -
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0);
+ 
+         // only accept rows where c = 1
 -        createView("mv_test", "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND c = 1 PRIMARY KEY (a, b, c)");
 -
 -        while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test"))
 -            Thread.sleep(10);
++        createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
++                   "WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND c = 1 " +
++                   "PRIMARY KEY (a, b, c)");
+ 
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0),
+                                 row(1, 0, 1, 0),
+                                 row(1, 1, 1, 0)
+         );
+ 
+         // insert new rows that do not match the filter
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, 2, 0);
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0),
+                                 row(1, 0, 1, 0),
+                                 row(1, 1, 1, 0)
+         );
+ 
+         // insert new row that does match the filter
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 1, 0);
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0),
+                                 row(1, 0, 1, 0),
+                                 row(1, 1, 1, 0),
+                                 row(1, 2, 1, 0)
+         );
+ 
+         // update rows that don't match the filter
+         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ?", 2, 2, 0);
+         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ?", 1, 2, 1);
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0),
+                                 row(1, 0, 1, 0),
+                                 row(1, 1, 1, 0),
+                                 row(1, 2, 1, 0)
+         );
+ 
+         // update a row that does match the filter
+         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ?", 1, 1, 0);
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0),
+                                 row(1, 0, 1, 1),
+                                 row(1, 1, 1, 0),
+                                 row(1, 2, 1, 0)
+         );
+ 
+         // delete rows that don't match the filter
+         execute("DELETE FROM %s WHERE a = ? AND b = ?", 2, 0);
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0),
+                                 row(1, 0, 1, 1),
+                                 row(1, 1, 1, 0),
+                                 row(1, 2, 1, 0)
+         );
+ 
+         // delete a row that does match the filter
+         execute("DELETE FROM %s WHERE a = ? AND b = ?", 1, 2);
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0),
+                                 row(1, 0, 1, 1),
+                                 row(1, 1, 1, 0)
+         );
+ 
+         // delete a partition that matches the filter
+         execute("DELETE FROM %s WHERE a = ?", 1);
 -        assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test"),
++        assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
+                                 row(0, 0, 1, 0),
+                                 row(0, 1, 1, 0)
+         );
+ 
 -        dropView("mv_test");
++        dropView();
+         dropTable("DROP TABLE %s");
+     }
+ 
+     @Test
+     public void complexRestrictedTimestampUpdateTestWithFlush() throws Throwable
+     {
+         complexRestrictedTimestampUpdateTest(true);
+     }
+ 
+     @Test
+     public void complexRestrictedTimestampUpdateTestWithoutFlush() throws Throwable
+     {
+         complexRestrictedTimestampUpdateTest(false);
+     }
+ 
+     public void complexRestrictedTimestampUpdateTest(boolean flush) throws Throwable
+     {
+         createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b))");
 -
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
+         Keyspace ks = Keyspace.open(keyspace());
+ 
 -        createView("mv", "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND c = 1 PRIMARY KEY (c, a, b)");
 -        ks.getColumnFamilyStore("mv").disableAutoCompaction();
++        String mv = createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
++                               "WHERE a IS NOT NULL AND b IS NOT NULL AND c IS NOT NULL AND c = 1 " +
++                               "PRIMARY KEY (c, a, b)");
++        ks.getColumnFamilyStore(mv).disableAutoCompaction();
+ 
+         //Set initial values TS=0, matching the restriction and verify view
 -        executeNet(version, "INSERT INTO %s (a, b, c, d) VALUES (0, 0, 1, 0) USING TIMESTAMP 0");
 -        assertRows(execute("SELECT d from mv WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0));
++        executeNet("INSERT INTO %s (a, b, c, d) VALUES (0, 0, 1, 0) USING TIMESTAMP 0");
++        assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0));
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
+         //update c's timestamp TS=2
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 2 SET c = ? WHERE a = ? and b = ? ", 1, 0, 0);
 -        assertRows(execute("SELECT d from mv WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0));
++        executeNet("UPDATE %s USING TIMESTAMP 2 SET c = ? WHERE a = ? and b = ? ", 1, 0, 0);
++        assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0));
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
+         //change c's value and TS=3, tombstones c=1 and adds c=0 record
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE a = ? and b = ? ", 0, 0, 0);
 -        assertRows(execute("SELECT d from mv WHERE c = ? and a = ? and b = ?", 0, 0, 0));
++        executeNet("UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE a = ? and b = ? ", 0, 0, 0);
++        assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 0, 0, 0));
+ 
 -        if(flush)
++        if (flush)
+         {
 -            ks.getColumnFamilyStore("mv").forceMajorCompaction();
++            ks.getColumnFamilyStore(mv).forceMajorCompaction();
+             FBUtilities.waitOnFutures(ks.flush());
+         }
+ 
+         //change c's value back to 1 with TS=4, check we can see d
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 4 SET c = ? WHERE a = ? and b = ? ", 1, 0, 0);
++        executeNet("UPDATE %s USING TIMESTAMP 4 SET c = ? WHERE a = ? and b = ? ", 1, 0, 0);
+         if (flush)
+         {
 -            ks.getColumnFamilyStore("mv").forceMajorCompaction();
++            ks.getColumnFamilyStore(mv).forceMajorCompaction();
+             FBUtilities.waitOnFutures(ks.flush());
+         }
+ 
 -        assertRows(execute("SELECT d, e from mv WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0, null));
++        assertRows(executeView("SELECT d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0, null));
+ 
+         //Add e value @ TS=1
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 1 SET e = ? WHERE a = ? and b = ? ", 1, 0, 0);
 -        assertRows(execute("SELECT d, e from mv WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0, 1));
++        executeNet("UPDATE %s USING TIMESTAMP 1 SET e = ? WHERE a = ? and b = ? ", 1, 0, 0);
++        assertRows(executeView("SELECT d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(0, 1));
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
+         //Change d value @ TS=2
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 2 SET d = ? WHERE a = ? and b = ? ", 2, 0, 0);
 -        assertRows(execute("SELECT d from mv WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(2));
++        executeNet("UPDATE %s USING TIMESTAMP 2 SET d = ? WHERE a = ? and b = ? ", 2, 0, 0);
++        assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(2));
+ 
+         if (flush)
+             FBUtilities.waitOnFutures(ks.flush());
+ 
+         //Change d value @ TS=3
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 3 SET d = ? WHERE a = ? and b = ? ", 1, 0, 0);
 -        assertRows(execute("SELECT d from mv WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(1));
++        executeNet("UPDATE %s USING TIMESTAMP 3 SET d = ? WHERE a = ? and b = ? ", 1, 0, 0);
++        assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row(1));
+ 
+         //Tombstone c
 -        executeNet(version, "DELETE FROM %s WHERE a = ? and b = ?", 0, 0);
 -        assertRowsIgnoringOrder(execute("SELECT d from mv"));
 -        assertRows(execute("SELECT d from mv"));
++        executeNet("DELETE FROM %s WHERE a = ? and b = ?", 0, 0);
++        assertRowsIgnoringOrder(executeView("SELECT d FROM %s"));
++        assertRows(executeView("SELECT d FROM %s"));
+ 
+         //Add back without D
 -        executeNet(version, "INSERT INTO %s (a, b, c) VALUES (0, 0, 1)");
++        executeNet("INSERT INTO %s (a, b, c) VALUES (0, 0, 1)");
+ 
+         //Make sure D doesn't pop back in.
 -        assertRows(execute("SELECT d from mv WHERE c = ? and a = ? and b = ?", 1, 0, 0), row((Object) null));
++        assertRows(executeView("SELECT d FROM %s WHERE c = ? and a = ? and b = ?", 1, 0, 0), row((Object) null));
+ 
+         //New partition
+         // insert a row with timestamp 0
 -        executeNet(version, "INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?) USING TIMESTAMP 0", 1, 0, 1, 0, 0);
++        executeNet("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?) USING TIMESTAMP 0", 1, 0, 1, 0, 0);
+ 
+         // overwrite pk and e with timestamp 1, but don't overwrite d
 -        executeNet(version, "INSERT INTO %s (a, b, c, e) VALUES (?, ?, ?, ?) USING TIMESTAMP 1", 1, 0, 1, 0);
++        executeNet("INSERT INTO %s (a, b, c, e) VALUES (?, ?, ?, ?) USING TIMESTAMP 1", 1, 0, 1, 0);
+ 
+         // delete with timestamp 0 (which should only delete d)
 -        executeNet(version, "DELETE FROM %s USING TIMESTAMP 0 WHERE a = ? AND b = ?", 1, 0);
 -        assertRows(execute("SELECT a, b, c, d, e from mv WHERE c = ? and a = ? and b = ?", 1, 1, 0),
++        executeNet("DELETE FROM %s USING TIMESTAMP 0 WHERE a = ? AND b = ?", 1, 0);
++        assertRows(executeView("SELECT a, b, c, d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 1, 0),
+                    row(1, 0, 1, null, 0)
+         );
+ 
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 2 SET c = ? WHERE a = ? AND b = ?", 1, 1, 1);
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE a = ? AND b = ?", 1, 1, 0);
 -        assertRows(execute("SELECT a, b, c, d, e from mv WHERE c = ? and a = ? and b = ?", 1, 1, 0),
++        executeNet("UPDATE %s USING TIMESTAMP 2 SET c = ? WHERE a = ? AND b = ?", 1, 1, 1);
++        executeNet("UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE a = ? AND b = ?", 1, 1, 0);
++        assertRows(executeView("SELECT a, b, c, d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 1, 0),
+                    row(1, 0, 1, null, 0)
+         );
+ 
 -        executeNet(version, "UPDATE %s USING TIMESTAMP 3 SET d = ? WHERE a = ? AND b = ?", 0, 1, 0);
 -        assertRows(execute("SELECT a, b, c, d, e from mv WHERE c = ? and a = ? and b = ?", 1, 1, 0),
++        executeNet("UPDATE %s USING TIMESTAMP 3 SET d = ? WHERE a = ? AND b = ?", 0, 1, 0);
++        assertRows(executeView("SELECT a, b, c, d, e FROM %s WHERE c = ? and a = ? and b = ?", 1, 1, 0),
+                    row(1, 0, 1, 0, 0)
+         );
+     }
+ 
+     @Test
+     public void testRestrictedRegularColumnTimestampUpdates() throws Throwable
+     {
+         // Regression test for CASSANDRA-10910
+ 
+         createTable("CREATE TABLE %s (" +
+                     "k int PRIMARY KEY, " +
+                     "c int, " +
+                     "val int)");
+ 
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
 -
 -        createView("mv_rctstest", "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE k IS NOT NULL AND c IS NOT NULL AND c = 1 PRIMARY KEY (k,c)");
++        createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
++                   "WHERE k IS NOT NULL AND c IS NOT NULL AND c = 1 " +
++                   "PRIMARY KEY (k,c)");
+ 
+         updateView("UPDATE %s SET c = ?, val = ? WHERE k = ?", 0, 0, 0);
+         updateView("UPDATE %s SET val = ? WHERE k = ?", 1, 0);
+         updateView("UPDATE %s SET c = ? WHERE k = ?", 1, 0);
 -        assertRows(execute("SELECT c, k, val FROM mv_rctstest"), row(1, 0, 1));
++        assertRows(executeView("SELECT c, k, val FROM %s"), row(1, 0, 1));
+ 
+         updateView("TRUNCATE %s");
+ 
+         updateView("UPDATE %s USING TIMESTAMP 1 SET c = ?, val = ? WHERE k = ?", 0, 0, 0);
+         updateView("UPDATE %s USING TIMESTAMP 3 SET c = ? WHERE k = ?", 1, 0);
+         updateView("UPDATE %s USING TIMESTAMP 2 SET val = ? WHERE k = ?", 1, 0);
+         updateView("UPDATE %s USING TIMESTAMP 4 SET c = ? WHERE k = ?", 1, 0);
+         updateView("UPDATE %s USING TIMESTAMP 3 SET val = ? WHERE k = ?", 2, 0);
 -        assertRows(execute("SELECT c, k, val FROM mv_rctstest"), row(1, 0, 2));
++        assertRows(executeView("SELECT c, k, val FROM %s"), row(1, 0, 2));
+     }
+ 
+     @Test
+     public void testOldTimestampsWithRestrictions() throws Throwable
+     {
+         createTable("CREATE TABLE %s (" +
+                     "k int, " +
+                     "c int, " +
+                     "val text, " + "" +
+                     "PRIMARY KEY(k, c))");
+ 
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
 -
 -        createView("mv_tstest", "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE val IS NOT NULL AND k IS NOT NULL AND c IS NOT NULL AND val = 'baz' PRIMARY KEY (val,k,c)");
++        createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
++                   "WHERE val IS NOT NULL AND k IS NOT NULL AND c IS NOT NULL AND val = 'baz' " +
++                   "PRIMARY KEY (val,k,c)");
+ 
+         for (int i = 0; i < 100; i++)
+             updateView("INSERT into %s (k,c,val)VALUES(?,?,?)", 0, i % 2, "baz");
+ 
+         Keyspace.open(keyspace()).getColumnFamilyStore(currentTable()).forceBlockingFlush();
+ 
+         Assert.assertEquals(2, execute("select * from %s").size());
 -        Assert.assertEquals(2, execute("select * from mv_tstest").size());
++        Assert.assertEquals(2, executeView("select * from %s").size());
+ 
+         assertRows(execute("SELECT val from %s where k = 0 and c = 0"), row("baz"));
 -        assertRows(execute("SELECT c from mv_tstest where k = 0 and val = ?", "baz"), row(0), row(1));
++        assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "baz"), row(0), row(1));
+ 
+         //Make sure an old TS does nothing
+         updateView("UPDATE %s USING TIMESTAMP 100 SET val = ? where k = ? AND c = ?", "bar", 0, 1);
+         assertRows(execute("SELECT val from %s where k = 0 and c = 1"), row("baz"));
 -        assertRows(execute("SELECT c from mv_tstest where k = 0 and val = ?", "baz"), row(0), row(1));
 -        assertRows(execute("SELECT c from mv_tstest where k = 0 and val = ?", "bar"));
++        assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "baz"), row(0), row(1));
++        assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "bar"));
+ 
+         //Latest TS
+         updateView("UPDATE %s SET val = ? where k = ? AND c = ?", "bar", 0, 1);
+         assertRows(execute("SELECT val from %s where k = 0 and c = 1"), row("bar"));
 -        assertRows(execute("SELECT c from mv_tstest where k = 0 and val = ?", "bar"));
 -        assertRows(execute("SELECT c from mv_tstest where k = 0 and val = ?", "baz"), row(0));
++        assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "bar"));
++        assertRows(executeView("SELECT c from %s where k = 0 and val = ?", "baz"), row(0));
+     }
+ }
diff --cc test/unit/org/apache/cassandra/cql3/ViewFilteringClustering1Test.java
index 8a976a0,841eb91..5283336
--- a/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering1Test.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering1Test.java
@@@ -22,15 -22,22 +22,17 @@@ import java.util.Arrays
  import java.util.List;
  
  import org.junit.Test;
 -import org.junit.runner.RunWith;
 -import org.junit.runners.Parameterized;
 -
 -import org.apache.cassandra.db.SystemKeyspace;
  
- /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670)
+ /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
   * Any changes here check if they apply to the other classes
   * - ViewFilteringPKTest
   * - ViewFilteringClustering1Test
   * - ViewFilteringClustering2Test
   * - ViewFilteringTest
+  * - ...
+  * - ViewFiltering*Test
   */
 -@RunWith(Parameterized.class)
 -public class ViewFilteringClustering1Test extends ViewFilteringTester
 +public class ViewFilteringClustering1Test extends ViewAbstractParameterizedTest
  {
      @Test
      public void testClusteringKeyEQRestrictions() throws Throwable
diff --cc test/unit/org/apache/cassandra/cql3/ViewFilteringClustering2Test.java
index 06b1945,219a807..450d87c
--- a/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering2Test.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering2Test.java
@@@ -22,15 -22,22 +22,17 @@@ import java.util.Arrays
  import java.util.List;
  
  import org.junit.Test;
 -import org.junit.runner.RunWith;
 -import org.junit.runners.Parameterized;
 -
 -import org.apache.cassandra.db.SystemKeyspace;
  
- /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670)
+ /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
   * Any changes here check if they apply to the other classes
   * - ViewFilteringPKTest
   * - ViewFilteringClustering1Test
   * - ViewFilteringClustering2Test
   * - ViewFilteringTest
+  * - ...
+  * - ViewFiltering*Test
   */
 -@RunWith(Parameterized.class)
 -public class ViewFilteringClustering2Test extends ViewFilteringTester
 +public class ViewFilteringClustering2Test extends ViewAbstractParameterizedTest
  {
      @Test
      public void testClusteringKeyMultiColumnRestrictions() throws Throwable
diff --cc test/unit/org/apache/cassandra/cql3/ViewFilteringComplexPKTest.java
index 06b1945,da089ca..d18883d
--- a/test/unit/org/apache/cassandra/cql3/ViewFilteringComplexPKTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringComplexPKTest.java
@@@ -22,24 -22,34 +22,26 @@@ import java.util.Arrays
  import java.util.List;
  
  import org.junit.Test;
 -import org.junit.runner.RunWith;
 -import org.junit.runners.Parameterized;
 -
 -import org.apache.cassandra.db.SystemKeyspace;
  
- /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670)
+ /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
   * Any changes here check if they apply to the other classes
   * - ViewFilteringPKTest
   * - ViewFilteringClustering1Test
   * - ViewFilteringClustering2Test
   * - ViewFilteringTest
+  * - ...
+  * - ViewFiltering*Test
   */
- public class ViewFilteringClustering2Test extends ViewAbstractParameterizedTest
 -@RunWith(Parameterized.class)
 -public class ViewFilteringComplexPKTest extends ViewFilteringTester
++public class ViewFilteringComplexPKTest extends ViewAbstractParameterizedTest
  {
      @Test
-     public void testClusteringKeyMultiColumnRestrictions() throws Throwable
+     public void testCompoundPartitionKeyRestrictions() throws Throwable
      {
          List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)");
          for (int i = 0; i < mvPrimaryKeys.size(); i++)
          {
-             createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))");
+             createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY ((a, b), c))");
  
 -            execute("USE " + keyspace());
 -            executeNet(version, "USE " + keyspace());
 -
              execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
              execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
              execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
@@@ -52,89 -61,163 +53,145 @@@
  
              logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i));
  
-             // only accept rows where b = 1
+             // only accept rows where a = 1 and b = 1
 -            createView("mv_test" + i, "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a = 1 AND b = 1 AND c IS NOT NULL PRIMARY KEY " + mvPrimaryKeys.get(i));
 -
 -            while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test" + i))
 -                Thread.sleep(10);
 +            createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                        "WHERE a IS NOT NULL AND (b, c) >= (1, 0) " +
++                       "WHERE a = 1 AND b = 1 AND c IS NOT NULL " +
 +                       "PRIMARY KEY " + mvPrimaryKeys.get(i));
  
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 1, 0, 0),
 -                                    row(1, 1, 1, 0)
 -            );
 +                                    row(1, 1, 1, 0));
  
              // insert new rows that do not match the filter
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, -1, 0, 0);
              execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, -1, 0);
+             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, 0, 0);
+             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 0, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 1, 0, 0),
 -                                    row(1, 1, 1, 0)
 -            );
 +                                    row(1, 1, 1, 0));
  
              // insert new row that does match the filter
              execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 2, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 1, 0, 0),
                                      row(1, 1, 1, 0),
 -                                    row(1, 1, 2, 0)
 -            );
 +                                    row(1, 1, 2, 0));
  
              // update rows that don't match the filter
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, -1, 0);
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, -1, 0);
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, 0, 0);
+             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 0, 0);
+             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 0, 0);
+             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 1, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 1, 0, 0),
                                      row(1, 1, 1, 0),
 -                                    row(1, 1, 2, 0)
 -            );
 +                                    row(1, 1, 2, 0));
  
              // update a row that does match the filter
              execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 1, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 1, 0, 1),
                                      row(1, 1, 1, 0),
 -                                    row(1, 1, 2, 0)
 -            );
 +                                    row(1, 1, 2, 0));
  
              // delete rows that don't match the filter
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, -1);
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, -1, 0);
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 0);
+             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 0, 0);
+             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 0, 0);
+             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 1, 0);
              execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 1, 0, 1),
                                      row(1, 1, 1, 0),
 -                                    row(1, 1, 2, 0)
 -            );
 +                                    row(1, 1, 2, 0));
  
              // delete a row that does match the filter
              execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 1, 1, 0),
 -                                    row(1, 1, 2, 0)
 -            );
 +                                    row(1, 1, 2, 0));
  
              // delete a partition that matches the filter
-             execute("DELETE FROM %s WHERE a = ?", 1);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 1, 0, 0),
-                                     row(0, 1, 1, 0));
- 
-             dropView();
-             dropTable("DROP TABLE %s");
+             execute("DELETE FROM %s WHERE a = ? AND b = ?", 1, 1);
 -            assertEmpty(execute("SELECT * FROM mv_test" + i));
++            assertEmpty(executeView("SELECT * FROM %s"));
          }
      }
  
      @Test
-     public void testClusteringKeyFilteringRestrictions() throws Throwable
+     public void testCompoundPartitionKeyRestrictionsNotIncludeAll() throws Throwable
+     {
+         createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY ((a, b), c))");
 -        execute("USE " + keyspace());
 -        executeNet(version, "USE " + keyspace());
+ 
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0);
+ 
+         // only accept rows where a = 1 and b = 1, don't include column d in the selection
 -        createView("mv_test", "CREATE MATERIALIZED VIEW %s AS SELECT a, b, c FROM %%s WHERE a = 1 AND b = 1 AND c IS NOT NULL PRIMARY KEY ((a, b), c)");
++        createView("CREATE MATERIALIZED VIEW %s AS SELECT a, b, c FROM %s " +
++                   "WHERE a = 1 AND b = 1 AND c IS NOT NULL " +
++                   "PRIMARY KEY ((a, b), c)");
+ 
 -        while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test"))
 -            Thread.sleep(10);
 -
 -        assertRows(execute("SELECT * FROM mv_test"),
++        assertRows(executeView("SELECT * FROM %s"),
+                    row(1, 1, 0),
 -                   row(1, 1, 1)
 -        );
++                   row(1, 1, 1));
+ 
+         // insert new rows that do not match the filter
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, 0, 0);
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 0, 0);
 -        assertRows(execute("SELECT * FROM mv_test"),
++        assertRows(executeView("SELECT * FROM %s"),
+                    row(1, 1, 0),
 -                   row(1, 1, 1)
 -        );
++                   row(1, 1, 1));
+ 
+         // insert new row that does match the filter
+         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 2, 0);
 -        assertRows(execute("SELECT * FROM mv_test"),
++        assertRows(executeView("SELECT * FROM %s"),
+                    row(1, 1, 0),
+                    row(1, 1, 1),
 -                   row(1, 1, 2)
 -        );
++                   row(1, 1, 2));
+ 
+         // update rows that don't match the filter
+         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 0, 0);
+         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 0, 0);
+         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 1, 0);
 -        assertRows(execute("SELECT * FROM mv_test"),
++        assertRows(executeView("SELECT * FROM %s"),
+                    row(1, 1, 0),
+                    row(1, 1, 1),
 -                   row(1, 1, 2)
 -        );
++                   row(1, 1, 2));
+ 
+         // update a row that does match the filter
+         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 1, 0);
 -        assertRows(execute("SELECT * FROM mv_test"),
++        assertRows(executeView("SELECT * FROM %s"),
+                    row(1, 1, 0),
+                    row(1, 1, 1),
 -                   row(1, 1, 2)
 -        );
++                   row(1, 1, 2));
+ 
+         // delete rows that don't match the filter
+         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 0, 0);
+         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 0, 0);
+         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 1, 0);
+         execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, 0);
 -        assertRows(execute("SELECT * FROM mv_test"),
++        assertRows(executeView("SELECT * FROM %s"),
+                    row(1, 1, 0),
+                    row(1, 1, 1),
 -                   row(1, 1, 2)
 -        );
++                   row(1, 1, 2));
+ 
+         // delete a row that does match the filter
+         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 0);
 -        assertRows(execute("SELECT * FROM mv_test"),
++        assertRows(executeView("SELECT * FROM %s"),
+                    row(1, 1, 1),
 -                   row(1, 1, 2)
 -        );
++                   row(1, 1, 2));
+ 
+         // delete a partition that matches the filter
+         execute("DELETE FROM %s WHERE a = ? AND b = ?", 1, 1);
 -        assertEmpty(execute("SELECT * FROM mv_test"));
++        assertEmpty(executeView("SELECT * FROM %s"));
+     }
+ 
+     @Test
+     public void testPartitionKeyAndClusteringKeyFilteringRestrictions() throws Throwable
      {
          List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)");
          for (int i = 0; i < mvPrimaryKeys.size(); i++)
@@@ -154,93 -240,71 +211,63 @@@
              logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i));
  
              // only accept rows where b = 1
 -            createView("mv_test" + i, "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a = 1 AND b IS NOT NULL AND c = 1 PRIMARY KEY " + mvPrimaryKeys.get(i));
 -
 -            while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test" + i))
 -                Thread.sleep(10);
 +            createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                        "WHERE a IS NOT NULL AND b IS NOT NULL AND c = 1 " +
++                       "WHERE a = 1 AND b IS NOT NULL AND c = 1 " +
 +                       "PRIMARY KEY " + mvPrimaryKeys.get(i));
  
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 0, 1, 0),
 -                                    row(1, 1, 1, 0)
 -            );
 +                                    row(1, 1, 1, 0));
  
              // insert new rows that do not match the filter
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, -1, 0);
+             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
+             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 0, 1, 0),
 -                                    row(1, 1, 1, 0)
 -            );
 +                                    row(1, 1, 1, 0));
  
              // insert new row that does match the filter
              execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 1, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 0, 1, 0),
                                      row(1, 1, 1, 0),
 -                                    row(1, 2, 1, 0)
 -            );
 +                                    row(1, 2, 1, 0));
  
              // update rows that don't match the filter
              execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, -1, 0);
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, 0, 0);
+             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 0, 1, 1, 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 0, 1, 0),
                                      row(1, 1, 1, 0),
 -                                    row(1, 2, 1, 0)
 -            );
 +                                    row(1, 2, 1, 0));
  
              // update a row that does match the filter
              execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 2, 1, 1, 1);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 0, 1, 0),
                                      row(1, 1, 1, 2),
 -                                    row(1, 2, 1, 0)
 -            );
 +                                    row(1, 2, 1, 0));
  
              // delete rows that don't match the filter
              execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, -1);
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, -1, 0);
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 0);
-             execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, -1);
+             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 1);
+             execute("DELETE FROM %s WHERE a = ?", 0);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 0, 1, 0),
                                      row(1, 1, 1, 2),
 -                                    row(1, 2, 1, 0)
 -            );
 +                                    row(1, 2, 1, 0));
  
              // delete a row that does match the filter
              execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 1);
 -            assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i),
 +            assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
                                      row(1, 0, 1, 0),
 -                                    row(1, 2, 1, 0)
 -            );
 +                                    row(1, 2, 1, 0));
  
              // delete a partition that matches the filter
              execute("DELETE FROM %s WHERE a = ?", 1);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0));
- 
-             // insert a partition with one matching and one non-matching row using a batch (CASSANDRA-10614)
-             String tableName = KEYSPACE + "." + currentTable();
-             execute("BEGIN BATCH " +
-                     "INSERT INTO " + tableName + " (a, b, c, d) VALUES (?, ?, ?, ?); " +
-                     "INSERT INTO " + tableName + " (a, b, c, d) VALUES (?, ?, ?, ?); " +
-                     "APPLY BATCH",
-                     4, 4, 0, 0,
-                     4, 4, 1, 1);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(0, 0, 1, 0),
-                                     row(0, 1, 1, 0),
-                                     row(4, 4, 1, 1));
 -            assertEmpty(execute("SELECT a, b, c, d FROM mv_test" + i));
++            assertEmpty(executeView("SELECT a, b, c, d FROM %s"));
  
 -            dropView("mv_test" + i);
 +            dropView();
              dropTable("DROP TABLE %s");
          }
      }
diff --cc test/unit/org/apache/cassandra/cql3/ViewFilteringSimplePKTest.java
index 24b32c7,d3b3e4a..9db70e6
--- a/test/unit/org/apache/cassandra/cql3/ViewFilteringSimplePKTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringSimplePKTest.java
@@@ -22,15 -22,22 +22,17 @@@ import java.util.Arrays
  import java.util.List;
  
  import org.junit.Test;
 -import org.junit.runner.RunWith;
 -import org.junit.runners.Parameterized;
 -
 -import org.apache.cassandra.db.SystemKeyspace;
  
- /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670)
+ /* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670, CASSANDRA-17167)
   * Any changes here check if they apply to the other classes
   * - ViewFilteringPKTest
   * - ViewFilteringClustering1Test
   * - ViewFilteringClustering2Test
   * - ViewFilteringTest
+  * - ...
+  * - ViewFiltering*Test
   */
- public class ViewFilteringPKTest extends ViewAbstractParameterizedTest
 -@RunWith(Parameterized.class)
 -public class ViewFilteringSimplePKTest extends ViewFilteringTester
++public class ViewFilteringSimplePKTest extends ViewAbstractParameterizedTest
  {
      @Test
      public void testPartitionKeyFilteringUnrestrictedPart() throws Throwable
@@@ -291,245 -331,7 +293,7 @@@
  
              // delete a partition that matches the filter
              execute("DELETE FROM %s WHERE a = ?", 1);
 -            assertEmpty(execute("SELECT * FROM mv_test" + i));
 +            assertEmpty(executeView("SELECT * FROM %s"));
          }
      }
- 
-     @Test
-     public void testCompoundPartitionKeyRestrictions() throws Throwable
-     {
-         List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)");
-         for (int i = 0; i < mvPrimaryKeys.size(); i++)
-         {
-             createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY ((a, b), c))");
- 
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0);
- 
-             logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i));
- 
-             // only accept rows where a = 1 and b = 1
-             createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                        "WHERE a = 1 AND b = 1 AND c IS NOT NULL " +
-                        "PRIMARY KEY " + mvPrimaryKeys.get(i));
- 
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 1, 0, 0),
-                                     row(1, 1, 1, 0));
- 
-             // insert new rows that do not match the filter
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 0, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 1, 0, 0),
-                                     row(1, 1, 1, 0));
- 
-             // insert new row that does match the filter
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 2, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 1, 0, 0),
-                                     row(1, 1, 1, 0),
-                                     row(1, 1, 2, 0));
- 
-             // update rows that don't match the filter
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 0, 0);
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 0, 0);
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 1, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 1, 0, 0),
-                                     row(1, 1, 1, 0),
-                                     row(1, 1, 2, 0));
- 
-             // update a row that does match the filter
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 1, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 1, 0, 1),
-                                     row(1, 1, 1, 0),
-                                     row(1, 1, 2, 0));
- 
-             // delete rows that don't match the filter
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 0, 0);
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 0, 0);
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 1, 0);
-             execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 1, 0, 1),
-                                     row(1, 1, 1, 0),
-                                     row(1, 1, 2, 0));
- 
-             // delete a row that does match the filter
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 1, 1, 0),
-                                     row(1, 1, 2, 0));
- 
-             // delete a partition that matches the filter
-             execute("DELETE FROM %s WHERE a = ? AND b = ?", 1, 1);
-             assertEmpty(executeView("SELECT * FROM %s"));
-         }
-     }
- 
-     @Test
-     public void testCompoundPartitionKeyRestrictionsNotIncludeAll() throws Throwable
-     {
-         createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY ((a, b), c))");
- 
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0);
- 
-         // only accept rows where a = 1 and b = 1, don't include column d in the selection
-         createView("CREATE MATERIALIZED VIEW %s AS SELECT a, b, c FROM %s " +
-                    "WHERE a = 1 AND b = 1 AND c IS NOT NULL " +
-                    "PRIMARY KEY ((a, b), c)");
- 
-         assertRows(executeView("SELECT * FROM %s"),
-                    row(1, 1, 0),
-                    row(1, 1, 1));
- 
-         // insert new rows that do not match the filter
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, 0, 0);
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 0, 0);
-         assertRows(executeView("SELECT * FROM %s"),
-                    row(1, 1, 0),
-                    row(1, 1, 1));
- 
-         // insert new row that does match the filter
-         execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 2, 0);
-         assertRows(executeView("SELECT * FROM %s"),
-                    row(1, 1, 0),
-                    row(1, 1, 1),
-                    row(1, 1, 2));
- 
-         // update rows that don't match the filter
-         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 0, 0);
-         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 0, 0);
-         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 0, 1, 0);
-         assertRows(executeView("SELECT * FROM %s"),
-                    row(1, 1, 0),
-                    row(1, 1, 1),
-                    row(1, 1, 2));
- 
-         // update a row that does match the filter
-         execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 1, 0);
-         assertRows(executeView("SELECT * FROM %s"),
-                    row(1, 1, 0),
-                    row(1, 1, 1),
-                    row(1, 1, 2));
- 
-         // delete rows that don't match the filter
-         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 0, 0);
-         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 0, 0);
-         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 0, 1, 0);
-         execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, 0);
-         assertRows(executeView("SELECT * FROM %s"),
-                    row(1, 1, 0),
-                    row(1, 1, 1),
-                    row(1, 1, 2));
- 
-         // delete a row that does match the filter
-         execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 0);
-         assertRows(executeView("SELECT * FROM %s"),
-                    row(1, 1, 1),
-                    row(1, 1, 2));
- 
-         // delete a partition that matches the filter
-         execute("DELETE FROM %s WHERE a = ? AND b = ?", 1, 1);
-         assertEmpty(executeView("SELECT * FROM %s"));
-     }
- 
-     @Test
-     public void testPartitionKeyAndClusteringKeyFilteringRestrictions() throws Throwable
-     {
-         List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)");
-         for (int i = 0; i < mvPrimaryKeys.size(); i++)
-         {
-             createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))");
- 
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, -1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0);
- 
-             logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i));
- 
-             // only accept rows where b = 1
-             createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
-                        "WHERE a = 1 AND b IS NOT NULL AND c = 1 " +
-                        "PRIMARY KEY " + mvPrimaryKeys.get(i));
- 
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 0, 1, 0),
-                                     row(1, 1, 1, 0));
- 
-             // insert new rows that do not match the filter
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 0, 1, 0),
-                                     row(1, 1, 1, 0));
- 
-             // insert new row that does match the filter
-             execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 1, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 0, 1, 0),
-                                     row(1, 1, 1, 0),
-                                     row(1, 2, 1, 0));
- 
-             // update rows that don't match the filter
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, -1, 0);
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 0, 1, 1, 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 0, 1, 0),
-                                     row(1, 1, 1, 0),
-                                     row(1, 2, 1, 0));
- 
-             // update a row that does match the filter
-             execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 2, 1, 1, 1);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 0, 1, 0),
-                                     row(1, 1, 1, 2),
-                                     row(1, 2, 1, 0));
- 
-             // delete rows that don't match the filter
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, -1);
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 1);
-             execute("DELETE FROM %s WHERE a = ?", 0);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 0, 1, 0),
-                                     row(1, 1, 1, 2),
-                                     row(1, 2, 1, 0));
- 
-             // delete a row that does match the filter
-             execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 1);
-             assertRowsIgnoringOrder(executeView("SELECT a, b, c, d FROM %s"),
-                                     row(1, 0, 1, 0),
-                                     row(1, 2, 1, 0));
- 
-             // delete a partition that matches the filter
-             execute("DELETE FROM %s WHERE a = ?", 1);
-             assertEmpty(executeView("SELECT a, b, c, d FROM %s"));
- 
-             dropView();
-             dropTable("DROP TABLE %s");
-         }
-     }
  }

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