dcapwell commented on code in PR #4879:
URL: https://github.com/apache/cassandra/pull/4879#discussion_r3424385933


##########
src/java/org/apache/cassandra/cql3/transactions/ConditionStatement.java:
##########
@@ -100,8 +106,19 @@ public ConditionStatement prepare(String keyspace, 
VariableSpecifications bindVa
             RowDataReference reference;
             Term value;
             boolean reversed = false;
-            
-            if (lhs instanceof RowDataReference.Raw)
+
+            if (lhs instanceof RowDataReference.Raw && rhs instanceof 
RowDataReference.Raw)
+            {
+                if (((RowDataReference.Raw) lhs).column() == null)
+                    throw new IllegalStateException(String.format("Row 
reference (%s) can only be used with IS NULL/IS NOT NULL conditions", 
lhs.getText()));
+                if (((RowDataReference.Raw) rhs).column() == null)
+                    throw new IllegalStateException(String.format("Row 
reference (%s) can only be used with IS NULL/IS NOT NULL conditions", 
rhs.getText()));
+                if (!((RowDataReference.Raw) 
lhs).column().type.equals(((RowDataReference.Raw) rhs).column().type))

Review Comment:
   I actually think `IllegalStateException` is the wrong type as we are 
validating the CQL, looking at `TransactionStatement` we use
   
   
   ```
   package org.apache.cassandra.exceptions;
   
   public class InvalidRequestException extends RequestValidationException
   ```
   
   from
   
   ```
       public static InvalidRequestException invalidRequest(String 
messageTemplate, Object... messageArgs)
       {
           return new InvalidRequestException(String.format(messageTemplate, 
messageArgs));
       }
   ```
   
   But back to the type thing.  its fine to go specific type and if we ever 
have the time we can do castable types; I think its far more work than just 
undoing this if condition so fine to leave as is for now



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