cql

selecting on two tables in Cassandra

二次信任 提交于 2019-12-24 05:22:15
问题 I use Cassandra for a project, and it's my first project. , and I'm trying to do a simple request on two tables, but that doesn't work... I want to do something like: Select * from table1, table2 where table1.test = test and table2.test2 = 123; Is it possible to request on two tables in Cassandra ? And how can I do that? Thanks 回答1: I'm trying to do a simple request on two tables What you're trying to do is known as a "distributed join" and Cassandra is specifically designed to prevent you

Cassandra CQL where clause with multiple collection values?

China☆狼群 提交于 2019-12-24 04:13:09
问题 My data model:- tid | codes | raw | type -------------------------------------+--------------+--------------+------ a64fdd60-1bc4-11e5-9b30-3dca08b6a366 | {12, 34, 53} | {sdafb=safd} | cmd CREATE TABLE MyTable ( tid TIMEUUID, type TEXT, codes SET<INT>, raw TEXT, PRIMARY KEY (tid) ); CREATE INDEX ON myTable (codes); How to query the table to return rows based on multiple set values. This works:- select * from logData where codes contains 34; But i want to get row based on multiple set values

Select in Cassandra with Java (datastax driver) by timestamp

不问归期 提交于 2019-12-24 01:17:20
问题 I am trying to do a SELECT in java into my Cassandra database. I am trying it with: Statement statement = QueryBuilder.select() .all() .from(keySpaceName, tableName) .where((QueryBuilder.eq("asset", categoryPos))) .and(QueryBuilder.gte("date", "2006-06-08 00:00:00")) .limit(10) .allowFiltering() .enableTracing(); The CQL query (already working) is SELECT * FROM pair_tick.price WHERE asset = 1 and date>='2006-06-08 15:30:00' LIMIT 10; When I am trying to execute this query, I get this error:

aggregate sum on Counter type of Cassandra

我的未来我决定 提交于 2019-12-23 17:18:31
问题 I'm using Cassandra 2.2.0, and I've read using Counter type but it doesn't provide much detail. Is there a way to aggregate on Counter type column for Cassandra, similar to the following? SELECT sum(my_counter_column) FROM my_table ; The above query results in this error: InvalidRequest: code=2200 [Invalid query] message="Invalid call to function sum, none of its type signatures match (known type signatures: system.sum : (tinyint) -> tinyint, system.sum : (smallint) -> smallint, system.sum :

RPC Timeout in Cassandra

一曲冷凌霜 提交于 2019-12-23 16:28:11
问题 I get the following error: cqlsh:dev> SELECT DISTINCT id FROM raw_data; Request did not complete within rpc_timeout. This is a special query that I'll never make again, I don't care how long it takes, and I don't want to change my schema (since I'll never make the query again...). How can I increase rpc_timeout for this one query? I have tried adding LIMIT 9999 and ALLOW FILTERING , and it doesn't help. I expect less than 1000 rows in the result. The query works on another Cassandra cluster

Cassandra Update and Delete in Clustering column Using IN operator

那年仲夏 提交于 2019-12-23 12:47:07
问题 This is my table CREATE TABLE quorum.omg ( id int, a int, b text, c text, PRIMARY KEY ((id, a), b) ) WITH CLUSTERING ORDER BY (b DESC) When i'am doing a select statement using IN operator, it works fine for last partition key and last clustering key SELECT * FROM omg WHERE id=1 AND a IN ( 1,2) AND b IN ( 'a','b' ) ; id | a | b | c ----+---+---+---- 1 | 1 | b | hi 1 | 2 | a | hi But when i do update and delete it is throwing error like this UPDATE omg SET c = 'lalala' WHERE id=1 AND a IN ( 1,2

Cassandra CQL wildcard search

◇◆丶佛笑我妖孽 提交于 2019-12-23 12:32:43
问题 I have a table structure like create table file(id text primary key, fname text, mimetype text, isdir boolean, location text); create index file_location on file (location); and following is the content in the table: insert into file (id, fname, mimetype, isdir, location) values('1', 'f1', 'pdf', False, 'c:/test/'); insert into file (id, fname, mimetype, isdir, location) values('2', 'f2', 'pdf', False, 'c:/test/'); insert into file (id, fname, mimetype, isdir, location) values('3', 'f3', 'pdf

Inserting null values into cassandra

佐手、 提交于 2019-12-23 09:44:40
问题 I have some fields that I am storing into Cassandra, but some of them could be null at any given point. As there are quite a lot of them, it makes the code much more readable if I don’t check each one for null before adding it to the INSERT. Is there any harm in doing so? EDIT!! There is a jira ticket that I found. But I am unable to understand what solution was finally implemented from the ticket. https://issues.apache.org/jira/browse/CASSANDRA-7304 回答1: The beautiful thing about Cassandra's

Dealing with Cassandra Timestamp

不问归期 提交于 2019-12-23 09:32:35
问题 Recently I have started working on cassandra and I have some issues dealing with cassandra timestamp using cql and Java. Below is my sample cassandra table schema. CREATE TABLE emp ( empid int, create_date timestamp, deptid int, PRIMARY KEY (empid, create_date) ) Here are my questions below: 1) Actually I need only date(I am not worried about time), In my table schema I have used timestamp datatype, Is there any datatype like date to store only date instead timestamp. 2) If there is no

cassandra primary key. performance implications if integer vs varchar

我与影子孤独终老i 提交于 2019-12-23 09:32:23
问题 In Cassandra , Will there be performance penalty if primary key is varchar instead of int or bigint ? I have id as primary key. I wont do any math operation on that. I use id just to insert,retrive compare. I want to change that to string for one of my requirements. Will the perforamnce go down ? 回答1: There won't be any noticeable difference. Primary key lookups are done on the token i.e. the hash of the key. The comparisons are therefore independent of the data type or size of the key.