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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 4734dfc503 Extend implicit allow-filtering for virtual tables to 
clustering columns
4734dfc503 is described below

commit 4734dfc503e6b4307b63dd61f36da9f9c89d86f9
Author: Stefan Miklosovic <smikloso...@apache.org>
AuthorDate: Mon Mar 13 12:51:34 2023 +0100

    Extend implicit allow-filtering for virtual tables to clustering columns
    
    patch by Stefan Miklosovic; reviewed by Aleksey Yeschenko for 
CASSANDRA-18331
---
 CHANGES.txt                                        |  1 +
 .../cql3/restrictions/StatementRestrictions.java   |  2 +-
 .../cassandra/cql3/statements/SelectStatement.java |  3 ++-
 .../cql3/validation/entities/VirtualTableTest.java | 24 ++++++++++++++++++++--
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 93b9125da8..f2b23b1f02 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.0
+ * Extend implicit allow-filtering for virtual tables to clustering columns 
(CASSANDRA-18331)
  * Upgrade maven-shade-plugin to 3.4.1 to fix shaded dtest JAR build 
(CASSANDRA-18136)
  * Upgrade to Opcodes.ASM9 (CASSANDRA-17971)
  * Add MaxSSTableSize and MaxSSTableDuration metrics and propagate them 
together with local read/write ratio to tablestats (CASSANDRA-18283)
diff --git 
a/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java 
b/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
index a7ebc2650b..d522f46d2f 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
@@ -286,7 +286,7 @@ public final class StatementRestrictions
             validateSecondaryIndexSelections();
     }
 
-    private boolean requiresAllowFilteringIfNotSpecified()
+    public boolean requiresAllowFilteringIfNotSpecified()
     {
         if (!table.isVirtual())
             return true;
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java 
b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 4d14ffa410..39e887cffd 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -1458,7 +1458,8 @@ public class SelectStatement implements 
CQLStatement.SingleKeyspaceCqlStatement
                 // We will potentially filter data if either:
                 //  - Have more than one IndexExpression
                 //  - Have no index expression and the row filter is not the 
identity
-                checkFalse(restrictions.needFiltering(), 
StatementRestrictions.REQUIRES_ALLOW_FILTERING_MESSAGE);
+                if (restrictions.requiresAllowFilteringIfNotSpecified())
+                    checkFalse(restrictions.needFiltering(), 
StatementRestrictions.REQUIRES_ALLOW_FILTERING_MESSAGE);
             }
         }
 
diff --git 
a/test/unit/org/apache/cassandra/cql3/validation/entities/VirtualTableTest.java 
b/test/unit/org/apache/cassandra/cql3/validation/entities/VirtualTableTest.java
index d27a894d61..a17f74cec2 100644
--- 
a/test/unit/org/apache/cassandra/cql3/validation/entities/VirtualTableTest.java
+++ 
b/test/unit/org/apache/cassandra/cql3/validation/entities/VirtualTableTest.java
@@ -1050,7 +1050,7 @@ public class VirtualTableTest extends CQLTester
     }
 
     @Test
-    public void testDisallowedFilteringOnTable() throws Throwable
+    public void testDisallowedFilteringOnRegularColumn() throws Throwable
     {
         try
         {
@@ -1064,11 +1064,31 @@ public class VirtualTableTest extends CQLTester
     }
 
     @Test
-    public void testAllowedFilteringOnTable() throws Throwable
+    public void testDisallowedFilteringOnClusteringColumn() throws Throwable
+    {
+        try
+        {
+            executeNet(format("SELECT * FROM %s.%s WHERE c = 'abc'", KS_NAME, 
VT5_NAME));
+            fail(format("should fail as %s.%s is not allowed to be filtered on 
implicitly.", KS_NAME, VT5_NAME));
+        }
+        catch (InvalidQueryException ex)
+        {
+            assertTrue(ex.getMessage().contains("Cannot execute this query as 
it might involve data filtering and thus may have unpredictable performance"));
+        }
+    }
+
+    @Test
+    public void testAllowedFilteringOnRegularColumn() throws Throwable
     {
         executeNet(format("SELECT * FROM %s.%s WHERE v2 = 5", KS_NAME, 
VT1_NAME));
     }
 
+    @Test
+    public void testAllowedFilteringOnClusteringColumn() throws Throwable
+    {
+        executeNet(format("SELECT * FROM %s.%s WHERE c = 'abc'", KS_NAME, 
VT1_NAME));
+    }
+
     @FunctionalInterface
     private static interface ThrowingRunnable
     {


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

Reply via email to