adelapena commented on code in PR #3444:
URL: https://github.com/apache/cassandra/pull/3444#discussion_r1724830392


##########
pylib/cqlshlib/cql3handling.py:
##########
@@ -738,11 +738,12 @@ def working_on_keyspace(ctxt):
                     ;
 <whereClause> ::= <relation> ( "AND" <relation> )*
                 ;
-<relation> ::= [rel_lhs]=<cident> ( "[" <term> "]" )? ( "=" | "<" | ">" | "<=" 
| ">=" | "CONTAINS" ( "KEY" )? ) <term>
+<relation> ::= [rel_lhs]=<cident> ( "[" <term> "]" )? ( "=" | "<" | ">" | "<=" 
| ">=" | "CONTAINS" ( "KEY" )? | "NOT CONTAINS" ( "KEY" )? ) <term>
              | token="TOKEN" "(" [rel_tokname]=<cident>
                                  ( "," [rel_tokname]=<cident> )*
-                             ")" ("=" | "<" | ">" | "<=" | ">=") 
<tokenDefinition>
+                             ")" ("=" | "!=" | "<" | ">" | "<=" | ">=") 
<tokenDefinition>
              | [rel_lhs]=<cident> "IN" "(" <term> ( "," <term> )* ")"
+             | [rel_lhs]=<cident> "NOT IN" "(" <term> ( "," <term> )* ")"

Review Comment:
   Rather than a new line, the previous one can be modified to:
   ```
   | [rel_lhs]=<cident> ( "NOT" )? "IN" "(" <term> ( "," <term> )* ")"
   ```
   This changes how autocompletion works. At the moment it's:
   ```
   cqlsh> SELECT * FROM k.t WHERE v
   <         <=        =         >         >=        BETWEEN   CONTAINS  IN     
   NOT       NOT IN    [
   ```
   While with the suggested change it would be:
   ```
   cqlsh> SELECT * FROM k.t WHERE v
   <         <=        =         >         >=        BETWEEN   CONTAINS  IN     
   NOT       [
   ```
   I think the latter is preferable, making it consistent with `CONTAINS`/`NOT 
CONTAINS`.



##########
pylib/cqlshlib/cql3handling.py:
##########
@@ -738,11 +738,12 @@ def working_on_keyspace(ctxt):
                     ;
 <whereClause> ::= <relation> ( "AND" <relation> )*
                 ;
-<relation> ::= [rel_lhs]=<cident> ( "[" <term> "]" )? ( "=" | "<" | ">" | "<=" 
| ">=" | "CONTAINS" ( "KEY" )? ) <term>
+<relation> ::= [rel_lhs]=<cident> ( "[" <term> "]" )? ( "=" | "<" | ">" | "<=" 
| ">=" | "CONTAINS" ( "KEY" )? | "NOT CONTAINS" ( "KEY" )? ) <term>

Review Comment:
   I think we are missing `!=`.



##########
pylib/cqlshlib/test/test_cqlsh_completion.py:
##########
@@ -473,7 +473,7 @@ def test_complete_in_delete(self):
         self.trycompletions('DELETE FROM twenty_rows_composite_table USING 
TIMESTAMP 0 WHERE TOKEN(a ',
                             choices=[')', ','])
         self.trycompletions('DELETE FROM twenty_rows_composite_table USING 
TIMESTAMP 0 WHERE TOKEN(a) ',
-                            choices=['>=', '<=', '=', '<', '>'])
+                            choices=['>=', '<=', '=', '<', '>', '!='])

Review Comment:
   While testing autocompletion, I have found that the queries with NEQ on 
token produce an unmanaged assertion error. For example:
   ```
   cqlsh> SELECT * FROM k.t WHERE TOKEN(k) != 1;
   NoHostAvailable: ('Unable to complete the operation against any hosts', 
{<Host: 127.0.0.1:9042 datacenter1>: <Error from server: code=0000 [Server 
error] message="java.lang.AssertionError">})
   ```
   And in logs:
   ```
   ERROR [Native-Transport-Requests-1] 2024-08-21 11:57:47,878 
ExceptionHandlers.java:229 - Unexpected exception during request; channel = 
[id: 0xcbd1f648, L:/127.0.0.1:9042 - R:/127.0.0.1:52126]
   java.lang.AssertionError: null
        at 
org.apache.cassandra.cql3.restrictions.PartitionKeyRestrictions.bounds(PartitionKeyRestrictions.java:143)
        at 
org.apache.cassandra.cql3.restrictions.StatementRestrictions.getPartitionKeyBounds(StatementRestrictions.java:778)
        at 
org.apache.cassandra.cql3.statements.SelectStatement.getRangeCommand(SelectStatement.java:794)
        at 
org.apache.cassandra.cql3.statements.SelectStatement.getQuery(SelectStatement.java:409)
        at 
org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:333)
        at 
org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:109)
        at 
org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:284)
        at 
org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:377)
        at 
org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:364)
        at 
org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:117)
        at 
org.apache.cassandra.transport.Message$Request.execute(Message.java:259)
        at 
org.apache.cassandra.transport.Dispatcher.processRequest(Dispatcher.java:416)
        at 
org.apache.cassandra.transport.Dispatcher.processRequest(Dispatcher.java:435)
        at 
org.apache.cassandra.transport.Dispatcher.processRequest(Dispatcher.java:462)
        at 
org.apache.cassandra.transport.Dispatcher$RequestProcessor.run(Dispatcher.java:307)
        at org.apache.cassandra.concurrent.FutureTask$1.call(FutureTask.java:99)
        at org.apache.cassandra.concurrent.FutureTask.call(FutureTask.java:61)
        at org.apache.cassandra.concurrent.FutureTask.run(FutureTask.java:71)
        at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:143)
        at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
   ```



##########
pylib/cqlshlib/test/test_cqlsh_completion.py:
##########
@@ -381,7 +381,7 @@ def test_complete_in_update(self):
         self.trycompletions("UPDATE empty_table SET lonelycol = 'eggs' WHERE 
lonel",
                             immediate='ykey ')
         self.trycompletions("UPDATE empty_table SET lonelycol = 'eggs' WHERE 
lonelykey ",
-                            choices=['=', '<=', '>=', '>', '<', 'BETWEEN', 
'CONTAINS', 'IN', '['])
+                            choices=['=', '<=', '>=', '>', '<', 'BETWEEN', 
'CONTAINS', 'NOT', 'CONTAINS', 'IN', 'NOT', 'IN', '['])

Review Comment:
   `NOT`, `CONTAINS` and `IN` are duplicated, and `!=` is missing.



##########
pylib/cqlshlib/test/test_cqlsh_completion.py:
##########
@@ -464,7 +464,7 @@ def test_complete_in_delete(self):
                             choices=['a', 'b', 'TOKEN('])
 
         self.trycompletions('DELETE FROM twenty_rows_composite_table USING 
TIMESTAMP 0 WHERE a ',
-                            choices=['<=', '>=', 'BETWEEN', 'CONTAINS', 'IN', 
'[', '=', '<', '>'])
+                            choices=['<=', '>=', 'BETWEEN', 'CONTAINS', 'NOT', 
'CONTAINS', 'IN', 'NOT', 'IN', '[', '=', '<', '>'])

Review Comment:
   Same as above, `NOT`, `CONTAINS` and `IN` are duplicated, and `!=` is 
missing.



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