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/09/02 12:47:35 UTC

[GitHub] [cassandra] adelapena commented on a change in pull request #1159: CASSANDRA-14344: Support filtering using IN restrictions

adelapena commented on a change in pull request #1159:
URL: https://github.com/apache/cassandra/pull/1159#discussion_r701047797



##########
File path: src/java/org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.java
##########
@@ -247,7 +249,22 @@ public final void addRowFilterTo(RowFilter filter,
                                          IndexRegistry indexRegistry,
                                          QueryOptions options)
         {
-            throw  invalidRequest("IN restrictions are not supported on indexed columns");
+            // If the relation is of the type (c) IN ((x),(y),(z)) then it is equivalent to
+            // c IN (x, y, z) and we can perform filtering
+            if (getColumnDefs().size() == 1)
+            {
+                List<List<ByteBuffer>> splitValues = splitValues(options);
+                List<ByteBuffer> values = new ArrayList<>(splitValues.size());
+                for (List<ByteBuffer> splitValue : splitValues)
+                    values.add(splitValue.get(0));
+
+                ByteBuffer buffer = ListSerializer.pack(values, values.size(), ProtocolVersion.V3);
+                filter.add(getFirstColumn(), Operator.IN, buffer);
+            }
+            else
+            {
+                throw invalidRequest("IN restrictions are not supported on indexed columns");

Review comment:
       Can we add a test verifying that an error with this message is triggered? I think that standard indexes won't even be selected due to to `Index#supportsExpression` returning `false` for the `IN` operator. SASI indexes would break if we use an `IN` operator, which is something that can be easily avoided with a simple check in `ColumnIndex#supports(Operator)`. And any other 3rd party indexes or the future SAI can decide whether they support the `IN` operator. wdyt?




-- 
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