maedhroz commented on code in PR #3645:
URL: https://github.com/apache/cassandra/pull/3645#discussion_r1829793757


##########
test/unit/org/apache/cassandra/index/sai/cql/AllowFilteringTest.java:
##########
@@ -296,6 +296,79 @@ public void 
testAllowFilteringOnClusteringAndRegularColumns() throws Throwable
         test("SELECT * FROM %s WHERE v1=0 AND v2=0 AND k1=0 AND k2=0 AND (c1, 
c2, c3, c4) = (0, 0, 0, 0) AND v3=0", true);
     }
 
+    @Test
+    public void testAllowFilteringTextWithINClause () throws Throwable
+    {
+        createTable("CREATE TABLE %S (K1 TEXT, K2 TEXT, K3 TEXT, PRIMARY 
KEY(K1))");
+        createIndex(format("CREATE CUSTOM INDEX ON %%s(K2) USING '%s'", 
StorageAttachedIndex.class.getName()));
+
+        execute("INSERT INTO %s (K1,K2,K3) VALUES ('s1','s11','s111')");
+        execute("INSERT INTO %s (K1,K2,K3) VALUES ('s2','s11','s11')");
+        execute("INSERT INTO %s (K1,K2,K3) VALUES ('s3','s22','s111')");
+        execute("INSERT INTO %s (K1,K2,K3) VALUES ('s4','s22','s111')");
+        execute("INSERT INTO %s (K1,K2,K3) VALUES ('s5','s31','s111')");
+
+        assertRowCount(execute("SELECT * FROM %s WHERE K2='s11' AND K3 IN 
('s11','s111') ALLOW FILTERING"),2);
+        assertRowCount(execute("SELECT * FROM %s WHERE K2='s22' AND K3 IN 
('s111','s111') ALLOW FILTERING"), 2);
+
+    }
+
+    @Test
+    public void testAllowFilteringIntWithINClause () throws Throwable
+    {
+        createTable("CREATE TABLE %S (K1 text, K2 int, K3 int, PRIMARY 
KEY(K1))");
+        createIndex(format("CREATE CUSTOM INDEX ON %%s(K2) USING '%s'", 
StorageAttachedIndex.class.getName()));
+
+        execute("insert into %s (k1,k2,k3) values ('s1',11,1)");
+        execute("insert into %s (k1,k2,k3) values ('s2',11,11)");
+        execute("insert into %s (k1,k2,k3) values ('s3',11,111)");
+        execute("insert into %s (k1,k2,k3) values ('s4',22,1)");
+        execute("insert into %s (k1,k2,k3) values ('s5',22,11)");
+        execute("insert into %s (k1,k2,k3) values ('s6',22,111)");
+
+        assertRowCount(execute("SELECT * FROM %s WHERE K2=11 AND K3 IN 
(1,11,111) ALLOW FILTERING"),3);
+        assertRowCount(execute("SELECT * FROM %s WHERE K2=22 AND K3 IN 
(1,11,111) ALLOW FILTERING"),3);
+
+    }
+
+    @Test
+    public void testAllowFilteringBigIntWithINClause () throws Throwable
+    {
+        {
+            createTable("CREATE TABLE %S (K1 text, K2 bigint, K3 bigint, 
PRIMARY KEY(K1))");
+            createIndex(format("CREATE CUSTOM INDEX ON %%s(K2) USING '%s'", 
StorageAttachedIndex.class.getName()));
+
+            execute("insert into %s (k1, k2, k3) values ('s1', 1001, 100)");
+            execute("insert into %s (k1, k2, k3) values ('s2', 1001, 200)");
+            execute("insert into %s (k1, k2, k3) values ('s3', 1001, 300)");
+            execute("insert into %s (k1, k2, k3) values ('s4', 2002, 100)");
+            execute("insert into %s (k1, k2, k3) values ('s5', 2002, 200)");
+            execute("insert into %s (k1, k2, k3) values ('s6', 2002, 300)");
+
+            assertRowCount(execute("SELECT * FROM %s WHERE K2=1001 AND K3 IN 
(100, 200, 300) ALLOW FILTERING"), 3);
+            assertRowCount(execute("SELECT * FROM %s WHERE K2=2002 AND K3 IN 
(100, 200, 300) ALLOW FILTERING"), 3);
+        }
+    }
+
+    @Test
+    public void testAllowFilteringBigDecimalWithINClause() throws Throwable
+    {
+        createTable("CREATE TABLE %S (K1 text, K2 decimal, K3 decimal, PRIMARY 
KEY(K1))");
+        createIndex(format("CREATE CUSTOM INDEX ON %%s(K2) USING '%s'", 
StorageAttachedIndex.class.getName()));
+
+        execute("insert into %s (k1, k2, k3) values ('s1', 1.1, 1.11)");
+        execute("insert into %s (k1, k2, k3) values ('s2', 1.1, 1.12)");
+        execute("insert into %s (k1, k2, k3) values ('s3', 1.1, 1.13)");
+        execute("insert into %s (k1, k2, k3) values ('s4', 2.2, 1.11)");
+        execute("insert into %s (k1, k2, k3) values ('s5', 2.2, 1.12)");
+        execute("insert into %s (k1, k2, k3) values ('s6', 2.2, 1.13)");
+
+        assertRowCount(execute("SELECT * FROM %s WHERE K2=1.1 AND K3 IN (1.11, 
1.12, 1.13) ALLOW FILTERING"), 3);
+        assertRowCount(execute("SELECT * FROM %s WHERE K2=2.2 AND K3 IN (1.11, 
1.12, 1.13) ALLOW FILTERING"), 3);

Review Comment:
   nit: Mentioned elsewhere, but let's make sure we have a couple negative 
tests that match zero rows just to make sure nothing crazy is going on...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to