cql3

Get current date in cassandra cql select

佐手、 提交于 2019-11-30 02:44:38
问题 In SQL, I am able to do: select getdate(), getdate() - 7 Which returns the current date as well as current date - 7 days. I want to achieve the same in Cassandra CQL. I tried: select dateof(now()) But that does not work. It works only on insert and not in select. How can I get the same? Any help would be appreciated. 回答1: select dateof(now()) On its own, you are correct, that does not work. But if you have a table that you know only has one row (like system.local ): aploetz@cqlsh

Iterating through Cassandra wide row with CQL3

随声附和 提交于 2019-11-30 02:17:51
How can I pull in a range of Composite columns with CQL3? Consider the following: CREATE TABLE Stuff ( a int, b text, c text, d text, PRIMARY KEY (a,b,c) ); In Cassandra what this effectively does is creates a ColumnFamily with integer rows (values of a) and with CompositeColumns composed of the values of b and c and the literal string 'd'. Of course this is all covered up by CQL3 so that we will think that we're inserting into individual database rows... but I digress. And consider the following set of inputs: INSERT INTO Stuff (a,b,c,d) VALUES (1,'A','P','whatever0'); INSERT INTO Stuff (a,b

Cassandra alter column type: which types are compatible?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 23:59:44
问题 There's some patchy information on the interwebs about some examples when column type can't be changed. For example, on the DataStax site there's a mention: Changing the type of a clustering column. Changing columns on which an index is defined. Or, for example, here is mentioned that you can't convert uuid to timeuuid . And from my personal experience, I can't change text to timestamp (we store dates in ISO8601 format as text, an unfortunate decision early in the project timeline). However,

Where and Order By Clauses in Cassandra CQL

旧城冷巷雨未停 提交于 2019-11-29 18:36:14
问题 I am new to NoSQL database and have just started using apache Cassandra. I created a simple table "emp" with primary key on "empno" column. This is a simple table as we always get in Oracle's default scott schema. Now I loaded data using the COPY command and issued query Select * from emp order by empno but I was surprised that CQL did not allow Order by on empno column (which is PK). Also when I used Where condition, it did not allow any inequality operations on empno column (it said only EQ

alter composite primary key in cassandra CQL 3.0

℡╲_俬逩灬. 提交于 2019-11-29 16:04:41
问题 I'm in a situation where I need to change the the composite primary key as follows: Old Primary Key: (id, source, attribute_name, updated_at); New Primary Key I want: (source, id, attribute_name, updated_at); I issued the following (mysql like) command: ALTER TABLE general_trend_table DROP PRIMARY KEY, ADD PRIMARY KEY(source, id, attribute_name, updated_at); I got the following error: Bad Request: line 1:38 no viable alternative at input 'PRIMARY' any idea how to get around this problem? more

Range query on secondary index in cassandra

徘徊边缘 提交于 2019-11-29 15:01:02
问题 I am using cassandra 2.1.10. So First I will clear that I know secondary index are anti-pattern in cassandra.But for testing purpose I was trying following: CREATE TABLE test_topology1.tt ( a text PRIMARY KEY, b timestamp ) WITH bloom_filter_fp_chance = 0.01 AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}' AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'} AND compression = {'sstable_compression': 'org.apache.cassandra.io

Apache Cassandra delete from counter

会有一股神秘感。 提交于 2019-11-29 13:14:26
I'm developing a little web application for studying Apache Cassandra and Java EE 6. Cassandra version is 1.1.6. Have a problem driving me mad... I created a table with a counter (using cqlsh v. 3.0.0) CREATE TABLE test ( author varchar PRIMARY KEY, tot counter ) and put some values this way: update test set tot = tot +1 where author = 'myAuthor'; the column family is perfectly updated author | tot ----------+----- myAuthor | 1 BUT, if you try to delete this row and then update again (with the same key), then nothing happens! The table is no more updated and I can't figure why: it seems to me

How to rename table in Cassandra CQL3

一曲冷凌霜 提交于 2019-11-29 11:08:46
问题 I'm trying to rename table created via CQLSH. E.g. rename table "AAA" to "BBB". Can't find any command to do so. Any ideas? Using [cqlsh 3.1.6 | Cassandra 1.2.8 | CQL spec 3.0.0 | Thrift protocol 19.36.0] 回答1: I don't believe you can rename tables or keyspaces, there's no CQL3 operation to do it, and nothing in the old Thirft interfaces either, if I remember correctly. One reason why you can't is that it would be an extremely hard thing for Cassandra to do due to its distributed nature, the

Cassandra cql: how to select the LAST n rows from a table

纵然是瞬间 提交于 2019-11-29 09:33:00
I want to verify that rows are getting added to the table. What cql statement would show the last n rows from the table below? Table description below: cqlsh:timeseries> describe table option_data; CREATE TABLE option_data ( ts bigint, id text, strike decimal, callask decimal, callbid decimal, maturity timestamp, putask decimal, putbid decimal, PRIMARY KEY ((ts), id, strike) ) WITH bloom_filter_fp_chance=0.010000 AND caching='KEYS_ONLY' AND comment='' AND dclocal_read_repair_chance=0.100000 AND gc_grace_seconds=864000 AND index_interval=128 AND read_repair_chance=0.000000 AND replicate_on

How do I set the consistency level of an individual CQL query in CQL3?

こ雲淡風輕ζ 提交于 2019-11-29 07:19:19
问题 In the earlier beta releases of CQL, there was a command I could use to set the read / write consistency of an individual CQL operation. It looked like this: SELECT * FROM users WHERE state='TX' USING CONSISTENCY QUORUM; I use CQL3 regularly and have a use-case where I need to be able to perform a read with a higher consistency level than the rest of our application. I looked through the CQL3 reference and didn't find any mention of any CQL syntax that allows me to change the consistency