Failure to execute cql script using cqlsh with nested SOURCE on DSE 5.1.2 - cassandra

I have a script I used to execute queries and DDL in DSE 4.8.10.
The script include nested use of the SOURCE command.
E.g.
1.sql
USE test;
SOURCE '2.sql'
exit;
2.sql
SELECT count(1) FROM user;
SOURCE '3.sql';
3.sql
SELECT count(1) FROM user;
When executing this script with DSE 4.8.10 it runs correctly and output
cqlsh –f 1.sql
count
--------
0
(1 rows)
count
--------
0
(1 rows)
Running the same script in DSE 5.1.2.
cqlsh –f 1.sql
count
-------
0
(1 rows)
Warnings :
Aggregation query used without partition key
2.sql:3:DSEShell instance has no attribute 'execution_profiles'
The actual issue is that the script in 3.sql is not executed.
I failed to find any useful information on the error
"DSEShell instance has no attribute 'execution_profiles'"
I failed to figure out what are execution_profiles although they are mentioned int the python docs here
Note: I am using python 2.7.7
Update
I did some additional investigations
With DSE-5.1.2 I switch the off to authenticator: AllowAllAuthenticator
authorizer: AllowAllAuthorizer, but I am still experiencing the issue
With DSE-5.1.1 it also happens
With DSE-5.0.9 it works
I failed to reproduce this in Apache Cassandra 3.11.0
Update 2: following support ticket we posted for Datastaxs we got a patch for this issue, I guess we should be expecting this to be fixed in the near feature.

As from DSE 5.1.4 this issue was resolved as part of DSP-14494.
See the 5.1.4 release notes
DSP-14494:Always define execution_profiles in cqlsh.py.
I tested this with 5.1.4 and the issue was resolved.

Related

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.

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

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.

InvalidRequestException Keyspace keyspace1 does not exist

I'm trying to connect to a Datastax Community Edition server 2.1.2 via JDBC but I keep getting the following error no matter what I try to do, even when issuing a very basic command like select * from system_traces.events;
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
Issuing that same command via cqlsh works properly, so it seems to be a JDBC issue.
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:229):229
at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:92):92
at java.sql.DriverManager.getConnection(DriverManager.java:664):664
at java.sql.DriverManager.getConnection(DriverManager.java:270):270
at railo.commons.db.DBUtil.getConnection(DBUtil.java:109):109
at railo.runtime.db.DatasourceConnectionPool.loadDatasourceConnection(DatasourceConnectionPool.java:89):89
at railo.runtime.db.DatasourceConnectionPool.getDatasourceConnection(DatasourceConnectionPool.java:81):81
at railo.runtime.db.DatasourceManagerImpl.getConnection(DatasourceManagerImpl.java:65):65
at railo.runtime.tag.Query.executeDatasoure(Query.java:696):696 ...
Any ideas? TIA!
InvalidRequestException(why:Keyspace 'keyspace1' does not exist)
This exception means you are trying to query for a keyspace (in this case "Keyspace1") that hasn't yet been added to Cassandra. Try creating the keyspace before querying it.
You're probably doing a select (SELECT * FROM "Keyspace1"."Standard1") that you're not seeing or passing initialisation parameters to JDBC telling it to connect to Keyspace1. Verify that your code isn't looking for the non-existent keyspace by searching through the queries you have, specifically looking for Keyspace1 (or "Keyspace1" since in this case the keyspace name is case-sensitive).
On a side-note, "Keyspace1"."Standard1" tend to be the standard ks.cf pair used for cassandra examples so it would be good to scan your code for them to make sure that they are created before they are queried.

Create table using cqlsh does not return to prompt

I am trying to create a table using cqlsh with composite primary key but it doesn't return to the cqlsh prompt. The cqlsh and cassandra versions are cqlsh 3.1.7 | Cassandra 1.2.13.2. Can we not create composite primary key using cqlsh? Have tried Dbeaver but that also fails reporting mismatched input ',' expecting EOF. Are there any other clients that allow to create?
Any suggestions would be helpful.
I tried your CREATE TABLE command on the same version of Cassandra using cql 3 and it just worked. It failed using cql 2.
If you're still using cql 2, that's likely the source of your problem.

Datastax Cassandra odbc driver and starting cql2 on cqlsh 3 gives error as cqlsh: error: no such option: -2

I have installed datastax ODBC driver for cassndra and also i have created keyspace and some tables using cql 3. But ODBC driver is not showing up those tables.
Also in odbc documentation i read that the driver does not currently support version 3.0 of the Cassandra Query Language (CQL3) and the driver will not recognize keyspaces and column families that are defined with CQL 3.
So in order to use cql 2 i am using following command which is suggested in driver documentation:
...\cqlsh” -2
But this is giving an error saying "cqlsh: error: no such option: -2"
Can anybody help me out with this?
cql2 is deprecated and was removed from cslqh in Cassandra 2.0. It will be removed from the server as well in 3.0.
I do not know when cql3 support will be added to the ODBC driver.
The documentation is not correct regarding how to start cqlsh using a previous spec/version...you need to use --cqlversion instead of -2 (see notes below). However, as mentioned in jbellis' answer cql2 support has been removed from later versions of cassandra.
CQL Shell for Apache Cassandra
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-C, --color Always use color output
--no-color Never use color output
-u USERNAME, --username=USERNAME
Authenticate as user.
-p PASSWORD, --password=PASSWORD
Authenticate using password.
-k KEYSPACE, --keyspace=KEYSPACE
Authenticate to the given keyspace.
-f FILE, --file=FILE Execute commands from FILE, then exit
-t TRANSPORT_FACTORY, --transport-factory=TRANSPORT_FACTORY
Use the provided Thrift transport factory function.
--debug Show additional debugging information
--cqlversion=CQLVERSION
Specify a particular CQL version (default: 3.1.1).
Examples: "3.0.3", "3.1.0"
-e EXECUTE, --execute=EXECUTE
Execute the statement and quit.

Resources