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