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: [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]