Is Cassandra Update IF statement where the condition is an inequality expression supported? - cassandra

Is UPDATE IF [condition] where [condition] is an inequality, supported by Cassandra CQL?
I had a look over the language reference and it seems that CQL should not be able to support the inequality through its grammar. I used the language reference from here: https://cassandra.apache.org/doc/cql3/CQL.html#updateStmt
What is confusing is that using the C# driver or CQLSH the query is executed successfully, but when doing the same thing from Datasax DevCenter I get an error.
I'm using a query similar to the one below:
UPDATE product
SET edit_date = [new_value]
WHERE customer_id = '4' AND code = 'AMZ-ISMDB'
IF edit_date < [new_value]
The results are as follows:
Datasax DevCenter throws an error when trying to execute the script snippet. The error I get is complaining about the inequality in the UPDATE IF part of the script.
There is one syntax error in the current script (see details below).
Please fix it and try again.
Line 29: no viable alternative at input '<'
If I use CLINQ with the Datasax C# driver the query is generated as above and when executed the update is persisted if the new edit_date is after the existing edit_date which is the expected behaviour.
Using CQLSH the query runs successfully and the update is persisted

The issue is most likely that DevCenter has not been updated to support the latest syntax.
Inequality conditions were added in:
CASSANDRA-6839
Looks like they missed updating the docs when that was added. I open CASSANDRA-10752 to get that fixed.

This issue has been fixed in DevCenter version 1.6.0.

Related

Push in existing local table failure (windows): InvalidRegionNumberException then IllegalArgumentException

I want to push data into an already existing table, single column family, no records.
I am using shc-core:1.1.1-2.1-s_2.11 on a windows machine. I have hbase 1.2.6 installed and use scala 2.11.8.
When I try to push data I got first the following error: org.apache.spark.sql.execution.datasources.hbase.InvalidRegionNumberException: Number of regions specified for new table must be greater than 3.
After following the advice of this link https://github.com/hortonworks-spark/shc/issues/249#issue-318285217, I added: HBaseTableCatalog.newTable -> "5" to my options.
It still failed but with: java.lang.IllegalArgumentException: Can not create a Path from a null string.
Following this link: https://github.com/hortonworks-spark/shc/issues/151#issuecomment-313800739, I added to my catalog: , "tableCoder":"PrimitiveType".
Still facing the same error.
I saw people are expecting some clarification about this issue (https://github.com/hortonworks-spark/shc/issues/249#issuecomment-463528032).
It is known issue and apparently it seems fixed (https://github.com/hortonworks-spark/shc/issues/155#issuecomment-315236736).
I do not know what to do next.
Is there a solution about this?

Cassandra no viable alternative at input Like

I am very new to Cassandra and am trying to use the new LIKE feature but keep getting the error
Line 1: no viable alternative at input 'LIKE'
I am using DataStax DevCenter and am following the examples on https://docs.datastax.com/en/cql/3.3/cql/cql_using/useSASIIndex.html .I am using Cassandra version 3.7.0 and CQL 3.4.2 and the Datastex version is 1.60 community . I have a table named zips with a text field called city that has 10,000 records and am simply using this CQL code
SELECT * FROM "MyTable".zips WHERE city LIKE 'M%';
Before that I added an index using
CREATE CUSTOM INDEX fn_prefix ON "MyTable".zips (city) USING 'org.apache.cassandra.index.sasi.SASIIndex';
I know that the index worked because it allowed me to do this query
SELECT * FROM "Exoler".zips WHERE city='Miami';
without using allow filter and it returns values. Any suggestions would be great as stated I am very new to this.
If you use Cassandra 3.9 and Datastax DevCenter version 1.5.0 or 1.6.0 it won't support LIKE (atleast on Windows). The result is only "no viable alternative at input 'LIKE'"
But it works fine if you use command prompt:
WINDOWS-Key
cmd
"%CASSANDRA_HOME%\bin\cqlsh"
It is just a bug in Datastax DevCenter I guess.

DevCenter reports syntax error but same CQL runs on cqlsh

I was trying to create a User Defined Function using Devcenter.
http://docs.datastax.com/en/cql/3.3/cql/cql_using/useCreateUDF.html
The following example was taken from the above link.
CREATE OR REPLACE FUNCTION fLog (input double) CALLED ON NULL INPUT RETURNS double LANGUAGE java AS 'return Double.valueOf(Math.log(input.doubleValue()));';
It works in cqlsh but fails in DevCenter with the following error. Based on how fast I get the response, I think DevCenter does a local syntax check and aborts execution as it thinks the query is wrong.
I am using Cassandra 2.2.3 and DevCenter 1.4.1
DevCenter does perform it's own grammar syntax checking as well as semantic validation.
This is a DevCenter bug - the column name "input" is not being allowed by the grammar in this context because it's also a CQL keyword that's incorrectly not being allowed here.
A suggested workaround until a fix is available is to change the name of the column, e.g. "inputvalue".
As it says "No viable alternative at input 'input'"
It seems like 'input' is a reserved keyword in Devcenter and not in the CQLSH.
Try using another name for the variable.

Syntax error at position 7: no viable alternative at input 'table'

Environment:
Cassandra and CLI version is 1.2.12
OS Windows7 Enterprise, 64 Bit.
ran cassendra-cli.bat, When running the create table command I get following:
[default#unknown] create table us(name varchar); Syntax error at
position 7: no viable alternative at input 'table'
Any idea why its throwing error ?
You are using the older CLI client. This is pre-CQL and uses the Thrit API. If you want to use that client then check out the older docs. The general view is that CQL is the way to go though.
To use CQL use the CQLSH client instead.
One thing to note, even in CQL your statement is not valid. You must specify a primary key.
create table us(name varchar, primary key (name));

int object has no attribute replace when trying to run a CQL command in cassandra

I have a counter column family in cassandra. When i try to view the data from CQL i get an error even though there is data in the column family.
SELECT * from userstats;
Generates the following error:
'int' object has no attribute 'replace'
I can confirm that the data is in the column family and is working properly since I can view the data with the Datastax Opscenter data explorer.
It sounds like you're using an older version of cqlsh. Upgrading it (just copying the bin/cqlsh file from the Cassandra 1.1 branch head, along with everything under the pylib directory, into place) ought to solve this.
If it doesn't, running cqlsh with --debug would help a lot in diagnosing the problem.

Resources