cql

Problem to load .csv files into Apache Cassandra with Python

旧时模样 提交于 2021-02-11 13:17:33
问题 I'm trying to load a .csv file with Python into Apache Cassandra database. The command "COPY" integrated with session.execute seems don't work. It gives an unexpected indent in correspondance of =',' but...I red something about and I found that the command COPY in this way is not supported. In this script time_test and p are two float variables from cassandra.cluster import Cluster cluster = Cluster() session = cluster.connect('myKEYSPACE') rows = session.execute('COPY table_test (time_test,

Cassandra: filtering based one specific value in a set

房东的猫 提交于 2021-02-10 15:46:08
问题 I have a data table in Cassandra and one of the columns is: customer_favourites , with each value being of type set and it has the details of each customer's favourite foods. For example one customer could have {'Mexican', 'Italian', 'Indian'} and another customer could have {'Mexican', 'French'} and another could have {'Mexican'} . I have the following code: SELECT customer_id, customer_fname, customer_lname FROM customers WHERE customer_favourites CONTAINS ‘Mexican’ ALLOW FILTERING; I want

How do I set CONSISTENCY to SERIAL in cqlsh?

眉间皱痕 提交于 2021-02-10 14:23:59
问题 I am trying to experiment with lightweight transactions in Cassandra by using SERIAL consistency. However, trying to set the consistency level in cqlsh results in an error: cqlsh:learning> CONSISTENCY SERIAL; Improper CONSISTENCY command. The WITH CONSISTENCY statement has been removed from CQL and so I cannot use that. Is there a way to enable serial consistency from cqlsh? Or do I have to do it using a driver? 回答1: The CONSISTENCY command should still work in cqlsh. But valid values for

How do I set CONSISTENCY to SERIAL in cqlsh?

我怕爱的太早我们不能终老 提交于 2021-02-10 14:23:05
问题 I am trying to experiment with lightweight transactions in Cassandra by using SERIAL consistency. However, trying to set the consistency level in cqlsh results in an error: cqlsh:learning> CONSISTENCY SERIAL; Improper CONSISTENCY command. The WITH CONSISTENCY statement has been removed from CQL and so I cannot use that. Is there a way to enable serial consistency from cqlsh? Or do I have to do it using a driver? 回答1: The CONSISTENCY command should still work in cqlsh. But valid values for

Range query on clustering key

不想你离开。 提交于 2021-02-10 06:31:12
问题 I have a table where I am logging user activity performed on my website. My table structure looks like: CREATE TABLE key_space.log ( id uuid, time bigint, ip text, url text, user_id int, PRIMARY KEY (id, time) ) WITH CLUSTERING ORDER BY (time DESC) Now I want to fetch all the records which came in last 5 minutes. For doing the same, I am using select * from key_space.log where time>current_timestamp - 5 minutes ALLOW FILTERING; But this query is not returning any result & i am getting

Check CQL version with Cassandra and cqlsh?

独自空忆成欢 提交于 2021-02-05 20:47:39
问题 How do you check which cql version is currently being used in cqlsh? In sql, you do this: Select @@version 回答1: There are a couple of ways to go about this. From within cqlsh, you can simply show version . aploetz@cqlsh> show version [cqlsh 5.0.1 | Cassandra 2.1.8 | CQL spec 3.2.0 | Native protocol v3] However, that only works from within cqlsh. Fortunately, you can also query system.local for that information as well. aploetz@cqlsh> SELECT cql_version FROM system.local; cql_version ---------

Cassandra order by second clustering key

放肆的年华 提交于 2021-01-29 09:35:58
问题 I have a table in cassandra and I want to order by the second clustering column and leave the first clustering column. It is the table definition: CREATE TABLE table1 ( key int, value1 text, value2 text, value3 text, comments text, PRIMARY KEY (key, value1, value2, value3) )WITH CLUSTERING ORDER BY (value2 DESC); I know that the above script is wrong and I should change it below: CREATE TABLE table1 ( key int, value1 text, value2 text, value3 text, comments text, PRIMARY KEY (key, value1,

Limiting columns per record in CQL

左心房为你撑大大i 提交于 2021-01-29 03:28:30
问题 I've a problem which has been bothering me from quite while now. I'm scaling it down for simplification. I've a column family in Cassandra defined as: CREATE TABLE "Test" ( key text, column1 text, value text, PRIMARY KEY (key, column1) ) If I run a query in CQL as: select * from "Test" where key in ('12345','34567'); It gives me something like: key | column1 | value -----------------------+--- 12345 | 764 | 764 12345 | 836 | 836 12345 | 123723 | 123723 12345 | 155863 | 155863 key | column1 |

How can I add a new field in a Cassandra table with default value “whatever”?

匆匆过客 提交于 2021-01-27 05:32:00
问题 How can I add a new field/column in a Cassandra table with default value "whatever" ? I know how to add a new column, however, need it to be set to a certain value. 回答1: There is no cell default value in cassandra. Best option is to in your application identify null values and change it to the default. 来源: https://stackoverflow.com/questions/48749253/how-can-i-add-a-new-field-in-a-cassandra-table-with-default-value-whatever