cql

What causes “no viable alternative at input 'None'” error with Cassandra CQL

戏子无情 提交于 2019-12-04 01:56:17
I'm attempting to insert a modified document back to Cassandra DB with a new key. I'm having hard time figuring out what is the issue the error message is pointing at. When looking for others that have had similar problems the answers seem to be related to the keys, and in my case the None is just a value of few of the keys. How do I solve this issue? keys = ','.join(current.keys()) params = [':' + x for x in current.keys()] values = ','.join(params) query = "INSERT INTO wiki.pages (%s) Values (%s)" % (keys, values) query = query.encode('utf-8') cursor.execute(query, current) Here's the data

How to get last inserted row in Cassandra?

自作多情 提交于 2019-12-04 01:00:08
问题 I want to get last inserted row in Cassandra table. How to get it? Any idea? I am developing a project for that I am replacing mysql with cassandra. I want to get rid off all sql queries and writing them all in cassandra. 回答1: Just to impart a little understanding... As with all Cassandra query problems, the query needs to be served by model specifically designed for it. This is known as query-based modeling. Querying the last inserted row is not an intrinsic capability built into every table

“Bad Request: PRIMARY KEY part to_id cannot be restricted” when trying to select using where condition

三世轮回 提交于 2019-12-03 20:39:50
Here is my cassandra table for chat kind of application: CREATE TABLE tax_keyspace_dev.chat_messages ( message text, when timestamp, from_id text, to_id text, read boolean, participants text, PRIMARY KEY(participants, when, to_id) ); This query work: select * from tax_keyspace_dev.chat_messages where participants='caone@one.com_shashank_shrivastava@acme.com' order by when; but following queries don't work: select * from tax_keyspace_dev.chat_messages where to_id='caone@one.com' order by when; Error is " Bad Request: PRIMARY KEY part to_id cannot be restricted (preceding part when is either not

Insert to cassandra from python using cql

你离开我真会死。 提交于 2019-12-03 17:33:26
问题 I'm planning to insert data to bellow CF that has compound keys. CREATE TABLE event_attend ( event_id int, event_type varchar, event_user_id int, PRIMARY KEY (event_id, event_type) #compound keys... ); But I can't insert data to this CF from python using cql. (http://code.google.com/a/apache-extras.org/p/cassandra-dbapi2/) import cql connection = cql.connect(host, port, keyspace) cursor = connection.cursor() cursor.execute("INSERT INTO event_attend (event_id, event_type, event_user_id) VALUES

How does the Leveled Compaction Strategy ensure 90% of reads are from one sstable

空扰寡人 提交于 2019-12-03 13:13:53
问题 I am trying to understand how the Leveled Compaction Strategy in Cassandra works that guarantees 90% of all reads will be satisfied from a single sstable. From DataStax Doc: new sstables are added to the first level, L0, and immediately compacted with the sstables in L1. When L1 fills up, extra sstables are promoted to L2. Subsequent sstables generated in L1 will be compacted with the sstables in L2 with which they overlap. 回答1: LeveledCompactionStrategy (LCS) in Cassandra implements the

How to use cql queries to get different datatypes out of cassandra with java client hector

自古美人都是妖i 提交于 2019-12-03 12:41:30
I'm new to cassandra and hector so i'm trying to execute cql queries but the problem is that not all columns are of type string so how dow I execute the query "select * from users"? My column family looks like this: UPDATE COLUMN FAMILY users WITH comparator = UTF8Type AND key_validation_class=UTF8Type AND column_metadata = [ {column_name: full_name, validation_class: UTF8Type} {column_name: email, validation_class: UTF8Type} {column_name: state, validation_class: UTF8Type, index_type: KEYS} {column_name: gender, validation_class: UTF8Type} {column_name: birth_year, validation_class: LongType,

When are rows overwritten in cassandra

為{幸葍}努か 提交于 2019-12-03 12:39:38
My understanding that rows are overwritten when another row with identical primary keys is inserted. For example: I have columns (user_id int, item_id int, site_id int) , and my PRIMARY KEY(user_id, item_id) If I had the following table: user_id, item_id, site_id 2 3 4 and I insert user_id : 2, item_id : 3, site_id : 10 , my new table would be: user_id, item_id, site_id 2 3 10 not user_id, item_id, site_id 2 3 4 2 3 10 Is this simple case hold in all cases? Are any subtleties that I likely not aware off? Also, I could not find this in the docs and came to this conclusion by playing around with

Cassandra IN query not working if table has SET type column

流过昼夜 提交于 2019-12-03 12:38:55
问题 I am new to Cassandra. I got a issue in CQL IN query ,if table has SET type column it works. CREATE TABLE test ( test_date bigint, test_id bigint, caption text, PRIMARY KEY(test_date,test_id) ); select * from test where test_date = 2022015 and test_id IN (1,2); but if I add tags set in above then it gives error CREATE TABLE test1 ( test_date bigint, test_id bigint, tags set<text>, caption text, PRIMARY KEY(test_date,test_id) ); select * from test1 where test_date = 2022015 and test_id IN (1,2

Range Queries in Cassandra (CQL 3.0)

寵の児 提交于 2019-12-03 12:37:01
One main part of Cassandra that I don't fully understand is its range queries. I know that Cassandra emphasizes distributed environment and focuses on performance, but probably because of that, it currently only support several types of ranges queries that it can finish efficiently, and what I would like to know is that: which types of range queries are supported by Cassandra. As far as I know, Cassandra supports the following range queries: 1: Range Queries on Primary key with keyword TOKEN , for example: CREATE TABLE only_int (int_key int PRIMARY KEY); ... select * from only_int where token

SELECT DISTINCT cql ignores WHERE clause

被刻印的时光 ゝ 提交于 2019-12-03 11:48:59
Executing two identical requests but the DISTINCT keyword gives unexpected results. Without the keyword, the result is ok but with DISTINCT, it looks like the where clause is ignored. Why ? Cqlsh version: Connected to Test Cluster at localhost:9160. [cqlsh 4.1.1 | Cassandra 2.0.6 | CQL spec 3.1.1 | Thrift protocol 19.39.0] Table considered: DESCRIBE TABLE events; CREATE TABLE events ( userid uuid, "timestamp" timestamp, event_type text, data text, PRIMARY KEY (userid, "timestamp", event_type) ) WITH bloom_filter_fp_chance=0.010000 AND caching='KEYS_ONLY' AND comment='' AND dclocal_read_repair