blerer commented on code in PR #3095:
URL: https://github.com/apache/cassandra/pull/3095#discussion_r1568822127
##########
src/java/org/apache/cassandra/cql3/Operator.java:
##########
@@ -324,23 +561,150 @@ public static Operator readFrom(DataInput input) throws
IOException
throw new IOException(String.format("Cannot resolve Relation.Type
from binary representation: %s", b));
}
+
/**
* Whether 2 values satisfy this operator (given the type they should be
compared with).
*/
public abstract boolean isSatisfiedBy(AbstractType<?> type, ByteBuffer
leftOperand, ByteBuffer rightOperand);
- public int serializedSize()
+
+ public boolean isSatisfiedBy(CollectionType<?> type, ComplexColumnData
leftOperand, ByteBuffer rightOperand)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public static int serializedSize()
{
return 4;
}
+ public void validateFor(ColumnsExpression expression)
+ {
+ if (!this.canBeUsedWith(expression.kind()))
+ throw invalidRequest("%s cannot be used with %s relations", this,
expression);
+
+ switch (expression.kind())
+ {
+ case SINGLE_COLUMN:
+ ColumnMetadata firstColumn = expression.firstColumn();
+ AbstractType<?> columnType = firstColumn.type;
+ if (isSlice())
+ {
+ if (columnType.referencesDuration())
+ {
+ checkFalse(columnType.isCollection(), "Slice
restrictions are not supported on collections containing durations");
+ checkFalse(columnType.isTuple(), "Slice restrictions
are not supported on tuples containing durations");
+ checkFalse(columnType.isUDT(), "Slice restrictions are
not supported on UDTs containing durations");
+ throw invalidRequest("Slice restrictions are not
supported on duration columns");
+ }
+ }
+ else
+ {
+ checkFalse(appliesToMapKeys() && !(columnType instanceof
MapType), "Cannot use %s on non-map column %s", this, firstColumn.name);
+ checkFalse(appliesToCollectionElements() &&
!columnType.isCollection(), "Cannot use %s on non-collection column %s", this,
firstColumn.name);
+ }
+
+ case MAP_ELEMENT:
+ ColumnMetadata column = expression.firstColumn();
+ AbstractType<?> type = column.type;
+ if (type.isMultiCell())
Review Comment:
There is no break in the previous `case`.
--
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]