Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CQL no viable alternative at input '(' error

I have a issue with my CQL and cassandra is giving me no viable alternative at input '(' (...WHERE id = ? if [(]...) error message. I think there is a problem with my statement.

UPDATE <TABLE> USING TTL 300 
  SET <attribute1> = 13381990-735b-11e5-9bed-2ae6d3dfc201
  WHERE <attribute2> = dfa2efb0-7247-11e5-a9e5-0242ac110003 
    IF (<attribute1> = null OR <attribute1> = 13381990-735b-11e5-9bed-2ae6d3dfc201) AND <attribute3> = 0; 

Any idea were the problem is in the statement about?

like image 326
imalik8088 Avatar asked Feb 18 '26 18:02

imalik8088


1 Answers

It would help to have your complete table structure, so to test your statement I made a couple of educated guesses.

With this table:

CREATE TABLE lwtTest (attribute1 timeuuid, attribute2 timeuuid PRIMARY KEY, attribute3 int);

This statement works, as long as I don't add the lightweight transaction on the end:

UPDATE lwttest USING TTL 300 SET attribute1=13381990-735b-11e5-9bed-2ae6d3dfc201 
WHERE attribute2=dfa2efb0-7247-11e5-a9e5-0242ac110003;

Your lightweight transaction...

IF (attribute1=null OR attribute1=13381990-735b-11e5-9bed-2ae6d3dfc201) AND attribute3 = 0;

...has a few issues.

  • "null" in Cassandra is not similar (at all) to its RDBMS counterpart. Not every row needs to have a value for every column. Those CQL rows without values for certain column values in a table will show "null." But you cannot query by "null" since it isn't really there.
  • The OR keyword does not exist in CQL.
  • You cannot use extra parenthesis to separate conditions in your WHERE clause or your lightweight transaction.

Bearing those points in mind, the following UPDATE and lightweight transaction runs without error:

UPDATE lwttest USING TTL 300 SET attribute1=13381990-735b-11e5-9bed-2ae6d3dfc201 
WHERE attribute2=dfa2efb0-7247-11e5-a9e5-0242ac110003
IF attribute1=13381990-735b-11e5-9bed-2ae6d3dfc201 AND attribute3=0;

 [applied]
-----------
     False
like image 86
Aaron Avatar answered Feb 21 '26 15:02

Aaron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!