You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/12/27 19:37:53 UTC

[GitHub] [cassandra] subkanthi opened a new pull request #1373: [17198] Removed LIKE restriction in StatementRestrictions

subkanthi opened a new pull request #1373:
URL: https://github.com/apache/cassandra/pull/1373


   [17198] Removed LIKE restriction in StatementRestrictions


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cassandra] subkanthi commented on a change in pull request #1373: [17198] Removed LIKE restriction in StatementRestrictions

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #1373:
URL: https://github.com/apache/cassandra/pull/1373#discussion_r799638114



##########
File path: src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
##########
@@ -174,13 +174,8 @@ public StatementRestrictions(StatementType type,
             }
             else if (relation.isLIKE())
             {
+                // CASSANDRA-17198 Remove restrictions in LIKE statement.
                 Restriction restriction = relation.toRestriction(table, boundNames);
-
-                if (!type.allowUseOfSecondaryIndices() || !restriction.hasSupportingIndex(indexRegistry))
-                    throw new InvalidRequestException(String.format("LIKE restriction is only supported on properly " +
-                                                                    "indexed columns. %s is not valid.",
-                                                                    relation.toString()));
-

Review comment:
       Removed.




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cassandra] subkanthi commented on a change in pull request #1373: [17198] Removed LIKE restriction in StatementRestrictions

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #1373:
URL: https://github.com/apache/cassandra/pull/1373#discussion_r786849941



##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
##########
@@ -3191,4 +3191,20 @@ public void testCreatingUDFWithSameNameAsBuiltin_FullyQualifiedFunctionNameWorks
         execute("INSERT INTO %s (k1, k2) VALUES (uuid(), 'k2')");
         assertRowCount(execute("SELECT system.token(k1, k2) FROM %s"), 1);
     }
+
+    @Test
+    public void testLikeQueryWithoutFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1, k2))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");
+        assertRows(execute("SELECT k2 from %s where k2 like '%%Doe'"), row("John Doe"));
+    }

Review comment:
       Thanks, this test is actually passing now, let me also check the `PartitionKeySingleRestrictionSet `




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cassandra] subkanthi commented on a change in pull request #1373: [17198] Removed LIKE restriction in StatementRestrictions

Posted by GitBox <gi...@apache.org>.
subkanthi commented on a change in pull request #1373:
URL: https://github.com/apache/cassandra/pull/1373#discussion_r799752253



##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
##########
@@ -3191,4 +3191,20 @@ public void testCreatingUDFWithSameNameAsBuiltin_FullyQualifiedFunctionNameWorks
         execute("INSERT INTO %s (k1, k2) VALUES (uuid(), 'k2')");
         assertRowCount(execute("SELECT system.token(k1, k2) FROM %s"), 1);
     }
+
+    @Test
+    public void testLikeQueryWithoutFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1, k2))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");
+        assertRows(execute("SELECT k2 from %s where k2 like '%%Doe'"), row("John Doe"));
+    }
+
+    @Test
+    public void testLikeQueryWithFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");

Review comment:
       @bereng , Thanks added.




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cassandra] blerer commented on a change in pull request #1373: [17198] Removed LIKE restriction in StatementRestrictions

Posted by GitBox <gi...@apache.org>.
blerer commented on a change in pull request #1373:
URL: https://github.com/apache/cassandra/pull/1373#discussion_r786829664



##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
##########
@@ -3191,4 +3191,20 @@ public void testCreatingUDFWithSameNameAsBuiltin_FullyQualifiedFunctionNameWorks
         execute("INSERT INTO %s (k1, k2) VALUES (uuid(), 'k2')");
         assertRowCount(execute("SELECT system.token(k1, k2) FROM %s"), 1);
     }
+
+    @Test
+    public void testLikeQueryWithoutFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1, k2))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");
+        assertRows(execute("SELECT k2 from %s where k2 like '%%Doe'"), row("John Doe"));
+    }

Review comment:
       That test should not pass. For filtering on partition columns the `needFiltering` methods in `PartitionKeySingleRestrictionSet` need to be modified to return `true` when LIKE predicate are used. 

##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
##########
@@ -3191,4 +3191,20 @@ public void testCreatingUDFWithSameNameAsBuiltin_FullyQualifiedFunctionNameWorks
         execute("INSERT INTO %s (k1, k2) VALUES (uuid(), 'k2')");
         assertRowCount(execute("SELECT system.token(k1, k2) FROM %s"), 1);
     }
+
+    @Test
+    public void testLikeQueryWithoutFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1, k2))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");
+        assertRows(execute("SELECT k2 from %s where k2 like '%%Doe'"), row("John Doe"));
+    }
+
+    @Test
+    public void testLikeQueryWithFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");

Review comment:
       To ensure that filtering is properly working we should also have some rows that are rejected and that some of them have a null value for the column

##########
File path: src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
##########
@@ -174,13 +174,8 @@ public StatementRestrictions(StatementType type,
             }
             else if (relation.isLIKE())
             {
+                // CASSANDRA-17198 Remove restrictions in LIKE statement.
                 Restriction restriction = relation.toRestriction(table, boundNames);
-
-                if (!type.allowUseOfSecondaryIndices() || !restriction.hasSupportingIndex(indexRegistry))
-                    throw new InvalidRequestException(String.format("LIKE restriction is only supported on properly " +
-                                                                    "indexed columns. %s is not valid.",
-                                                                    relation.toString()));
-

Review comment:
       You can remove that if clause as it is now similar to the next one




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [cassandra] bereng commented on a change in pull request #1373: [17198] Removed LIKE restriction in StatementRestrictions

Posted by GitBox <gi...@apache.org>.
bereng commented on a change in pull request #1373:
URL: https://github.com/apache/cassandra/pull/1373#discussion_r799264354



##########
File path: test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
##########
@@ -3191,4 +3191,20 @@ public void testCreatingUDFWithSameNameAsBuiltin_FullyQualifiedFunctionNameWorks
         execute("INSERT INTO %s (k1, k2) VALUES (uuid(), 'k2')");
         assertRowCount(execute("SELECT system.token(k1, k2) FROM %s"), 1);
     }
+
+    @Test
+    public void testLikeQueryWithoutFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1, k2))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");
+        assertRows(execute("SELECT k2 from %s where k2 like '%%Doe'"), row("John Doe"));
+    }
+
+    @Test
+    public void testLikeQueryWithFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 uuid, k2 text, PRIMARY KEY (k1))");
+        execute("INSERT INTO %s (k1, k2) VALUES(uuid(), 'John Doe')");

Review comment:
       For completion I would add tests for all `LIKE`flavors: `LIKE_PREFIX, LIKE_SUFFIX, LIKE_CONTAINS, LIKE_MATCHES`




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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