blerer commented on code in PR #3095:
URL: https://github.com/apache/cassandra/pull/3095#discussion_r1567395471


##########
src/java/org/apache/cassandra/cql3/Relation.java:
##########
@@ -125,119 +105,28 @@ public final boolean isSlice()
      * @return the <code>Restriction</code> corresponding to this 
<code>Relation</code>
      * @throws InvalidRequestException if this <code>Relation</code> is not 
valid
      */
-    public final Restriction toRestriction(TableMetadata table, 
VariableSpecifications boundNames)
+    public SingleRestriction toRestriction(TableMetadata table, 
VariableSpecifications boundNames)
     {
-        switch (operator)
-        {
-            case EQ: return newEQRestriction(table, boundNames);
-            case LT: return newSliceRestriction(table, boundNames, Bound.END, 
false);
-            case LTE: return newSliceRestriction(table, boundNames, Bound.END, 
true);
-            case GTE: return newSliceRestriction(table, boundNames, 
Bound.START, true);
-            case GT: return newSliceRestriction(table, boundNames, 
Bound.START, false);
-            case IN: return newINRestriction(table, boundNames);
-            case CONTAINS: return newContainsRestriction(table, boundNames, 
false);
-            case CONTAINS_KEY: return newContainsRestriction(table, 
boundNames, true);
-            case IS_NOT: return newIsNotRestriction(table, boundNames);
-            case LIKE_PREFIX:
-            case LIKE_SUFFIX:
-            case LIKE_CONTAINS:
-            case LIKE_MATCHES:
-            case LIKE:
-                return newLikeRestriction(table, boundNames, operator);
-            case ANN:
-                throw invalidRequest("ANN is only supported in ORDER BY");
-            default: throw invalidRequest("Unsupported \"!=\" relation: %s", 
this);
-        }
-    }
-
-    /**
-     * Creates a new EQ restriction instance.
-     *
-     * @param table the table meta data
-     * @param boundNames the variables specification where to collect the bind 
variables
-     * @return a new EQ restriction instance.
-     * @throws InvalidRequestException if the relation cannot be converted 
into an EQ restriction.
-     */
-    protected abstract Restriction newEQRestriction(TableMetadata table, 
VariableSpecifications boundNames);
+        if (operator == Operator.NEQ)
+            throw invalidRequest("Unsupported '!=' relation: %s", this);

Review Comment:
   It is enforced at the grammar level and I believe that the approach was 
wrong. We should have a `IS NOT NULL` unary operator not an `IS NOT` binary 
operator as it forces you to handle use case that will never exist in practice. 
Once you will see the IS NOT NULL patch you will understand better what I have 
in mind.



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

Reply via email to