cql3

Does CQL3 require a schema for Cassandra now?

纵然是瞬间 提交于 2019-12-04 10:45:17
问题 I've just had a crash course of Cassandra over the last week and went from Thrift API to CQL to grokking SuperColumns to learning I shouldn't use them and user Composite Keys instead. I'm now trying out CQL3 and it would appear that I can no longer insert into columns that are not defined in the schema, or see those columns in a select * Am I missing some option to enable this in CQL3 or does it expect me to define every column in the schema (defeating the purpose of wide, flexible rows, imho

Upsert/Read into/from Cassandra database using Datastax API (using new Binary protocol)

帅比萌擦擦* 提交于 2019-12-04 06:16:37
问题 I have started working with Cassandra database . I am planning to use Datastax API to upsert/read into/from Cassandra database . I am totally new to this Datastax API (which uses new Binary protocol) and I am not able to find lot of documentations as well which have some proper examples. create column family profile with key_validation_class = 'UTF8Type' and comparator = 'UTF8Type' and default_validation_class = 'UTF8Type' and column_metadata = [ {column_name : crd, validation_class :

Query using composite keys, other than Row Key in Cassandra

故事扮演 提交于 2019-12-04 04:47:09
I want to query data filtering by composite keys other than Row Key in CQL3. These are my queries: CREATE TABLE grades (id int, date timestamp, subject text, status text, PRIMARY KEY (id, subject, status, date) ); When I try and access the data, SELECT * FROM grades where id = 1098; //works fine SELECT * FROM grades where subject = 'English' ALLOW FILTERING; //works fine SELECT * FROM grades where status = 'Active' ALLOW FILTERING; //gives an error Bad Request: PRIMARY KEY part status cannot be restricted (preceding part subject is either not restricted or by a non-EQ relation) Just to

Time series modelling( with start & end date) in cassandra

痴心易碎 提交于 2019-12-04 04:38:16
问题 I am doing time series data modelling where I have a start date and end date of events. I need to query on that data model like the following: Select * from tablename where startdate>'2012-08-09' and enddate<'2012-09-09' I referred to the following link on cql where clause but I couldn't achieve this. Any way to do that? I can also change the data model or any cql tweaks. I am using Cassandra 2.1. 回答1: I had to solve a similar problem in one of my former positions. This is one way in which

How to bind IN-clause values in a CQL 3 prepared statement?

旧街凉风 提交于 2019-12-04 03:53:13
问题 I have a table that is roughly like create table mytable ( id uuid, something text, primary key (id) ); I'm trying to create a prepared statement that has a bound in-clause: PreparedStatement ps = session.prepare("select * from mytable where id IN (?)"); ... UUID[] ids = { uuid1, uuid2, uuid3} ; No matter how I express the ids to bind, the java driver rejects them. ps.bind( /*as array*/) : driver complains statement has only one value, 2 supplied ps.bind( /*as comma separated string list of

How to keep 2 Cassandra tables within same partition

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 13:47:18
I tried reading up on datastax blogs and documentation but could not find any specific on this Is there a way to keep 2 tables in Cassandra to belong to same partition? For example: CREATE TYPE addr ( street_address1 text, city text, state text, country text, zip_code text, ); CREATE TABLE foo ( account_id timeuuid, data text, site_id int, PRIMARY KEY (account_id) }; CREATE TABLE bar ( account_id timeuuid, address_id int, address frozen<addr>, PRIMARY KEY (account_id, address_id) ); Here I need to ensure that both of these tables/CF will live on same partition that way for the same account_id

Modeling many-to-many relations in Cassandra 2 with CQL3

你说的曾经没有我的故事 提交于 2019-12-03 07:37:23
What is the canonical way to model many-to-many relations with CQL3 ? Let's say I have to tables CREATE TABLE actor ( id text PRIMARY KEY, given text, surname text, ) CREATE TABLE fan ( id text PRIMARY KEY, given text, surname text, ) and I'd like to model the fact that an actor can have many fan and each fan can like many actors. The first idea that came to my my was to use sets , like in the following (and the other way around for fans): CREATE TABLE actor ( id text PRIMARY KEY, given text, surname text, fans set<text> ) <similarly for fan> but it seems they are meant for small sets, and I

Does CQL3 require a schema for Cassandra now?

筅森魡賤 提交于 2019-12-03 07:32:10
I've just had a crash course of Cassandra over the last week and went from Thrift API to CQL to grokking SuperColumns to learning I shouldn't use them and user Composite Keys instead. I'm now trying out CQL3 and it would appear that I can no longer insert into columns that are not defined in the schema, or see those columns in a select * Am I missing some option to enable this in CQL3 or does it expect me to define every column in the schema (defeating the purpose of wide, flexible rows, imho). Yes, CQL3 does require columns to be declared before used. But, you can do as many ALTERs as you

determine node of a partition in Cassandra

孤者浪人 提交于 2019-12-02 05:27:59
问题 This is maybe a special question but is it possible to determine the node(s) of a partion key? example: I have a partition key id (int) and I'm using the default Partitioner(Murmur3Partitioner) with 3 nodes and replication factor "1". Can I determine the one node with id = 3? CREATE TABLE example_table ( id int, content text, PRIMARY KEY (id, content) ) 回答1: You can use nodetool getendpoints <keyspace> <table> <partition_key> or you can use select token(<partition_key>) from <table_name> and

unable to coerce '2012/11/11' to a formatted date (long)

五迷三道 提交于 2019-12-01 23:18:31
问题 I am new to Cassandra cql (cqlsh 4.1.1, Cassandra 2.0.8.39, CQL spec 3.1.1, Thrift protocol 19.39.0) - using the cql COPY command to a table from a CSV formatted file and I get the following error: Bad Request: unable to coerce '2012/11/11' to a formatted date (long) . How do I change a column using cql so that it accepts the date from my CSV file? 回答1: as Brian said, there are CQL timestamp type to follow to get CQL query running. Sometimes it looks like quite weird indeed ! I've got the