Questions tagged [cql]
CQL (Cassandra Query Language) is used to interact with and query Cassandra tables. Its syntax is similar to SQL, helping to lower the learning curve to working with Cassandra. For the Cypher graph query language, use the cypher tag.
2,086
questions
0
votes
1
answer
29
views
How do I count distinct values based on a non-primary key filter in Cassandra?
relational databases and Cassandra. With two tables like the following:
TABLE 1: PRIMARY KEY (ID, DATE));
ID
DATE
TRIP_TIME
B03291
2022-01-01
5
B03291
2022-01-02
6
ZR7875
2022-01-01
2
ZR7875
2022-...
0
votes
1
answer
42
views
Openlayers: Loading image while layer is invisible
I'm using Openlayers 7.
Is it possible to force the layer source (ImageWMS) to load a CQL filtered image, i.e. to buffer it, while the layer is not visible?
I would like to avoid the image from a ...
0
votes
0
answers
10
views
Request to Cassandra with a condition on a column that is not a Primary Key works in DBeaver but doesn't work in Python
My query has a WHERE on a column that is not a primary key.
SELECT * FROM table WHERE id_order IN ('2177579','2177130','2177072')
The query works fine in DBeaver, but when using the Cassandra library ...
1
vote
1
answer
58
views
How do I insert into a table with a frozen type with the Java driver?
I am trying to write a query to insert data in the table "users". How do I write the query to insert into users? And how do i write the code in Java
CREATE TYPE address (
street ...
2
votes
1
answer
47
views
Recommended Cassandra Schema to store application logs
I have been tasked to come up with a schema to store our application logs using Cassandra. I am quite new to Cassandra but from what I have read and learned so far, it could be the best approach for ...
1
vote
1
answer
24
views
Apache Cassandra CQL - Drop Multiple Tables
I have a query that I am running on Jupyter with Python 3 kernel. But I am getting an error. The code+query:
import cassandra
from cassandra.cluster import Cluster
cluster = Cluster()
session = ...
1
vote
2
answers
68
views
Codec not found for requested operation [decimal <-> java.lang.Double]
I have decimal value in Cassandra db how to get that value
cluster = Cluster.builder().addContactPoint("dev").withPort(9042).build();
cluster.getConfiguration().getCodecRegistry()....
1
vote
1
answer
40
views
How to get data in descending order of Timestame in cassandra
I have existing data table in cassandra date table with primary key is id
SELECT * FROM Op_History ORDER BY create_time DESC limit 100;
I tried this one but getting error as :
InvalidRequest: Error ...
0
votes
1
answer
33
views
Is it possible to use a hash type secondary index in scylladb?
Table for explanation:
CREATE TABLE test
(
id INT,
uniuque_string VARCHAR,
another_id INT,
PRIMARY KEY ((id, uniuque_string))
);
Sometimes it is necessary to make such ...
0
votes
1
answer
24
views
How to execute a .cql file inside a kubernetes pod?
I need to execute a .cql file inside a kubernetes pod.
I did not try anything
2
votes
1
answer
49
views
How do I get the last value of a CQL list column?
I'm using scylladb lists ( https://docs.scylladb.com/stable/cql/types.html#lists ). I created a same table from documentation:
CREATE TABLE plays (
id text PRIMARY KEY,
game text,
players ...
1
vote
1
answer
31
views
How can I filter for a specific date on a CQL timestamp column?
I have a table defined as:
CREATE TABLE downtime(
asset_code text,
down_start timestamp,
down_end timestamp,
down_duration duration,
down_type text,
down_reason text,
...
1
vote
1
answer
43
views
Offsetting a timestamp on a Cassandra query
Probably a dumb question but I'm using toTimestamp(now()) to retrieve the timestamp. Is there any way to offset the now() by my specified timeframe.
What I have now:
> print(session.execute('SELECT ...
2
votes
2
answers
72
views
Does it have an equivalent query in cql/cassandra for "alter table add column if column not exists"?
I need to add the column for table that if the column is not existed.
I ran the Alter Table <table> add <column_name> <type>; however, it will have this error message if the column ...
0
votes
2
answers
35
views
How can I design a table that stores subdomain metadata to avoid large partitions?
i try to design a table in cassandra, but im getting a lot of large partition messages.
Any ideas how i could improve this "design" to prevent overloading and still can use a query like this:...
0
votes
1
answer
90
views
Catching a specific exception on a drop column CQL statement in Clojure
I want to run a drop-column CQL statement on a table that may or may not have that column exist. Ideally I would like to do a if-exists then drop column, but I do not believe CQL supports that.
My ...
0
votes
2
answers
116
views
How do I properly grant permissions to a specific keyspace to a user and validate it?
In short, the statement GRANT SELECt ON KEYSPACE AAA TO user; not take effect when executing LIST ALL PERMISSIONS OF user;.
I find nothing when I google this.
0
votes
1
answer
32
views
CQL ALTER TABLE not working (add column + with properties)
I'm trying to run the following CQL command
ALTER TABLE keyspace_name_abc.table_name
ADD (field1 text, field2 text)
WITH default_time_to_live = 15552000;
But it is not working, the error I'm getting ...
-2
votes
1
answer
30
views
APACHE CASSANDRA DATASTAX
WANT TO COPY MY LOCAL FILES TO APACHE CASSANDRA CQL CONSOLE.
TRIED TO COPY THE LOCAL FILES BY USING ($ dsbulk load -url E:\svit\Apache cassandra\Learning Apache Cassandra - Working\event.csv -header ...
0
votes
0
answers
36
views
UPDATE cql is not working, table is not updating
My CQL:
UPDATE BBS_ID.users SET access_token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2RlIjoiNzIxMjk2IiwibmJmIjoxNjY4MTA0NTM5LCJleHAiOjE2NjgxMDgxMzgsImlhdCI6MTY2ODEwNDUzOX0.-1CSN-...
1
vote
2
answers
51
views
CQL query to return a boolean column based on a condition
Is it possible to retrieve a true/false answer from a CQL query that checks a condition -- for example, if a collection has a specific value?
Consider:
CREATE TABLE Test (Id text PRIMARY KEY, Roles ...
0
votes
0
answers
10
views
Rest API and CQL request with email address or hostname?
I have a rest api to search in a confluence but I failed to write the request when I want to search for an email address or a hostname.
When I use the following command line (just renamed some stuff ...
0
votes
1
answer
28
views
How do I execute a CQL statement inside a user-defined function?
I want to trigger the Cassandra query when the Java/JavaScript code if statement satisfied? For example:
CREATE OR REPLACE FUNCTION f1 (val1 int, val2int)
CALLED ON NULL INPUT
RETURN int
...
1
vote
1
answer
51
views
Can I change the order of rows without specifying a column as the clustering key?
I know I can change the on-disk sorting to descending by defining a table like this:
create table timeseries (
event_type text,
insertion_time timestamp,
event blob,
PRIMARY KEY (event_type, ...
1
vote
1
answer
127
views
Unable to create keyspace with the Python driver, getting Unauthorized error "Missing correct permission"
I am trying to create a keyspace on my `Astra' instance but I have gotten this error while trying the execute the CREATE statement:
---------------------------------------------------------------------...
0
votes
1
answer
70
views
Can I set a column to the value of another column in CQL?
I'm new to cassandra and I'm trying to create a new column witch content is based on another column.
More precisely what I want to achive is, starting with following table:
ColumnA
ColumnB
1
text
I ...
0
votes
0
answers
70
views
Apply cql to cassandra on bare metal during application deployment to kubernetes cluster
Our customer has a running cassandra cluster (not in a container).
We are currently trying to find a way to apply cql scripts in an automated way during rollout of our application that is deployed in ...
0
votes
0
answers
9
views
CAP framework CQL UPDATE with timestamp comparison or case-when statement
I am trying to UPDATE an entity set with a where condition containing the comparison of two timestamps. However, this is not working, as somehow the timestamps can't be compared (I don't get any hits ...
1
vote
1
answer
29
views
Cassandra client's execute function return an error if the query contains a comment
I need to make a query to a Cassandra database using the execute function of the Cassandra client provided by the package cassandra-driver.
Here is the code:
const cassandraClient = new cassandra....
1
vote
2
answers
110
views
ConfigurationException: Unable to find custom indexer class 'StorageAttachedIndex'
I am having this error while trying to create a new custom index.
Is because of my cassandra setup? What can be done to solve this issue?
cqlsh:dblpa2> create CUSTOM INDEX ON publication(entries(...
2
votes
2
answers
244
views
Best way to Fetch N rows in ScyllaDB
I have a use case in which I utilize ScyllaDB to limit users' actions in the past 24h. Let's say the user is only allowed to make an order 3 times in the last 24h. I am using ScyllaDB's ttl and making ...
0
votes
1
answer
111
views
How do I group by date in Cassandra?
I'm trying to find a query in Cassandra cql to group by date. I have "date" datatype where the date is like: "mm-dd-yyyy". I'm just trying to extract the year and then group by. ...
1
vote
2
answers
122
views
Cannot create materialized view using SELECT query with PER PARTITION LIMIT
Table:
CREATE TABLE IF NOT EXISTS table (
a TEXT,
b TEXT,
c BIGINT,
PRIMARY KEY ((a, b), c)
) WITH CLUSTERING ORDER BY (c DESC);
I need to get only one record from each (a, ...
0
votes
1
answer
22
views
How can I access two Cassandra rows as inputs to a UDF?
Like the title, In CASSANDRA, I'm trying to access 2 different row values belonging to different columns at the same time to perform an operation (like addition).
Elaboration: Let's say I have 3 ...
2
votes
2
answers
84
views
Can you change the partition key of a particular row in a Cassandra table?
I am unsure if you can change the partition key value of a particular row in a table. For example, if you had a table such that the PRIMARY KEY(name, title) and have some entry where name = "John&...
1
vote
2
answers
45
views
Does Cassandra's CQL support the modulo operator for filtering queries?
I need to make a selection by the value of the remainder of the division:
cqlsh> SELECT * FROM table WHERE key%10=1;
Invalid syntax at line 1, char 39
SELECT * FROM table WHERE key%10=1;
...
1
vote
1
answer
125
views
Invalid STRING constant OR mismatched input ':' expecting '}' - Cassandra DB
I have two issues:
When I am executing the code below:
public void insertFarmers(int id, HashMap<String, String> the_farmer, List delivery) {
Cluster cluster = Cluster.builder()
....
1
vote
2
answers
93
views
Bind list to Cassandra WHERE clause: getting "Codec not found for requested operation: [list<varchar> <-> scala.collection.immutable.$colon$colon]"
I am trying to bind a Scala List after the "IN" keyword in a CQL WHERE clause.
I tried this
val session: com.datastax.driver.core.Session = ...
val deleteStatement = session.prepare(s"...
0
votes
0
answers
29
views
How to update denormalized tables in Cassandra
I'm new to Cassandra world. Actually I'm trying to create a chat application for my users (traders). I have a table as below to find traders by a room_id.
CREATE TABLE IF NOT EXISTS traders_by_room (
...
0
votes
1
answer
50
views
Row uniqueness in Cassandra table with PRIMARY KEY (hash, created)
I'm trying to create a table containing 2 columns, one of which is a unique hash and another is the timestamp of when the row was created.
CREATE TABLE IF NOT EXISTS keyspace.table (
account ...
1
vote
2
answers
58
views
Cassandra(Amazon keyspace) Query Error on clustered columns
I am trying execute query on clustering columns on amazon keyspace, since I don't want to use ALLOW FILTERING with my native query I have created 4-5 clustering columns for better performance.
But ...
2
votes
1
answer
51
views
How do I switch between column types in Cassandra?
I have a function in my project that deals with row results from query, and switches between the column types. The problem with doing this with Cassandra, is that I can't switch between the types, ...
0
votes
1
answer
282
views
Can JDBC be used with Cassandra?
I have generic functions in my project that handle each database type, whether it's MySql or Oracle and more by using Statement and JDBC Connection.
However when I try using them for supporting ...
0
votes
1
answer
889
views
How do I create a Cassandra keyspace automatically with docker-compose?
I have a golang service that run in a container, along with a cassandra db.
This is running like this :
services:
cassandra:
image: cassandra:4.0
...
healthcheck:
test: [&...
1
vote
2
answers
152
views
Cassandra doesn't comply with consistency settings, QUORUM is set but ALL is used
we have a mistake on some read query. Somtimes query fails because it doesn't reached the consistency ALL, but we have asked consistency QUORUM.
It's happen only on read query (not write).
Our ...
1
vote
1
answer
109
views
Golang cassandra gocql transaction need a delay time to executed
This block of code does not delete the data, I don't know why.
s.Query(
"INSERT INTO smth (id, name) VALUES (?,?)",
data.ID
data.Name
).ScanCAS(nil, nil, nil)
s....
1
vote
2
answers
500
views
In Scylla DB, How can I query the records for multiple condition and without mentioning ALLOW FILTERING?
I have a table in ScyllaDB:
CREATE TABLE taxiservice.operatoragentsauditlog (
hourofyear int,
operationtime bigint,
action text,
actiontype text,
appname text,
entityid text,
...
1
vote
1
answer
46
views
I need a regex that finds substrings in a CQL string split by occurrences of AND and OR outside quotes and taking escaped quotes into account
In this example source string:
index1 = "searchterm1" AND (index2 any "\"value2.1\" \"value2.2 AND sometext\" \"value2.3 OR sometext\"") OR index3 = &...
1
vote
1
answer
83
views
How can I run the CQL query "(col1, col2) IN ((1,2), (3,4))" with GoCQLX?
Well, the title may be not quite informative, sorry.
If I use
qb.Select(...)
.Where(
qb.Eq("part_key_col1"),
qb.Eq("part_key_col1"),
qb.In("clust_key_col1")...
0
votes
1
answer
50
views
Is there a big performance difference with Cassandra LWTs?
I have a similar question, but it's not clear, so I'm asking myself. Simple. I want to update only when there is a target row, and if it doesn't, it shouldn't be done. (No new rows should be added.)
...