cql3

CQL with a wide row - how to get most recent set?

安稳与你 提交于 2019-12-12 10:54:19
问题 How would I write the CQL to get the most recent set of data from each row? I'm investigating transitioning from MSSQL to Cassandra and am starting to grasp the concepts. Lots of research has help tremendously, but I haven't found answer to this (I know there must be a way): CREATE TABLE WideData { ID text, Updated timestamp, Title text, ReportData text, PRIMARY KEY (ID, Updated) } WITH CLUSTERING ORDER (Updated DESC) INSERT INTO WideData (ID, Updated, Title, ReportData) VALUES ('aaa', NOW,

Astyanax Cassandra Double type precision

自作多情 提交于 2019-12-12 10:47:43
问题 I'm trying to get a Double value from a Cassandra table with a double type column. I've created the table in CQL3 syntax: CREATE TABLE data_double ( datetime timestamp, value double, primary key (datetime) ); I've inserted a row: INSERT INTO data_double (datetime, value) VALUES ('111111111', 123.456); When I do: SELECT * from data_double; I get that the value is 123.46 Why is the value rounded? Thanks 回答1: The cqlsh utility by default will only display 5 digits of precision for floating point

User Defined Type (UDT) behavior in Cassandra

不羁的心 提交于 2019-12-12 09:19:05
问题 if someone has some experience in using UDT (User Defined Types), I would like to understand how the backward compatibility would work. Say I have the following UDT CREATE TYPE addr ( street1 text, zip text, state text ); If I modify "addr" UDT to have a couple of more attributes (say for example zip_code2 int, and name text): CREATE TYPE addr ( street1 text, zip text, state text, zip_code2 int, name text ); how does the older rows that does have these attributes work? Is it even compatible?

How to keep 2 Cassandra tables within same partition

北战南征 提交于 2019-12-12 07:59:26
问题 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

InvalidQueryException when trying to create column family in Cassandra via unit

你。 提交于 2019-12-12 06:08:27
问题 I have a 3 node cassandra cluster and via my unit test in Java, I first create a keyspace and then create a column family within that keyspace. Sometimes the unit tests passes but randomly I keep getting the following error. I am using the latest datastax 2.1.4 java driver and the cassandra version in 2.1.0. com.symc.edp.database.nosql.NoSQLPersistenceException: com.datastax.driver.core.exceptions.InvalidQueryException: Cannot add column family 'testmaxcolumnstable' to non existing keyspace

Cassandra returns variable results when looking for time series data

人盡茶涼 提交于 2019-12-12 04:34:14
问题 When I give this query in DataStax DevCenter, 2 rows are returned. The rows returned are foe Dec 30th as they should be. SELECT * FROM abc.alerts_by_type_and_timestamp WHERE alert_type IN ('Permanent Fault', 'Temporary Fault') AND alert_timeStamp >= '2015-12-30T15:00+0000' AND alert_timeStamp <= '2015-12-31T15:00+0000' But running in PreparedStatement like this SELECT * FROM abc.alerts_by_type_and_timestamp WHERE alert_type IN :alertTypes AND alert_timeStamp >= :minTimestamp AND alert

Paging large resultsets in Cassandra with CQL3 with varchar keys

一曲冷凌霜 提交于 2019-12-12 01:43:37
问题 I’m working on updating an old thrift-based code to CQL3. One part of the code is walking through the entire dataset of a table consisting of 20M+ rows. This part was initially crashing the program due to memory usage, so I created a RowIterator class which iterated through the column family using TokenRanges (and Hector). When trying to rewrite this using CQL3, I’m having trouble paging through the data. I found some info over at http://www.datastax.com/documentation/cql/3.0/cql/cql_using

Strange behavior of timeuuid comparison

☆樱花仙子☆ 提交于 2019-12-11 21:28:29
问题 I have Cassandra 2.x cluster with 3 nodes and the db scheme like this: cqlsh> CREATE KEYSPACE test_ks WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 3} AND durable_writes = true; cqlsh> CREATE TABLE IF NOT EXISTS test_ks.test_cf ( ... time timeuuid, ... user_id varchar, ... info varchar, ... PRIMARY KEY (time, user_id) ... ) WITH compression = {'sstable_compression': 'LZ4Compressor'} AND compaction = {'class': 'LeveledCompactionStrategy'}; Lets add some data (wait some

Regular expression search or LIKE type feature in cassandra

淺唱寂寞╮ 提交于 2019-12-11 19:47:04
问题 I am using datastax cassandra ver 2.0. How do we search in cassandra column a value using regular expression.Is there way to achieve 'LIKE' ( as in sQL) functionality ? I have created table with below schema. CREATE TABLE Mapping ( id timeuuid, userid text, createdDate timestamp, createdBy text, lastUpdateDate timestamp, lastUpdateBy text, PRIMARY KEY (id,userid) ); I inserted few test records as below. id | userid | createdby -------------------------------------+----------+-----------

create Composite-keyed Table with cassandra-cli

ぃ、小莉子 提交于 2019-12-11 19:42:36
问题 i want to use php for my project with phpcassa which doesn't support cql, so if I understood right I have to code cassandra commands like I would with cassandra-cli. My question is how can I create a Composite-keyed Table or Dynamic Column Families like in this website, though not with cql but with cassandra-cli and where can I find more information about this language. 回答1: create column family myColumnFamily with key_validation_class = 'CompositeType(UUIDType,UTF8Type)' and comparator =