cqlsh

Is there a clear equivalent of 'show keyspaces' in cqlsh 2?

浪尽此生 提交于 2019-11-29 20:50:59
What cqlsh command can I use to quickly see the keyspaces in a cluster? cqlsh does not provide show keyspaces and describe cluster isn't as concise as I want. I'm working using the following specifications: cqlsh 2.2.0, Cassandra 1.1.10, CQL spec 2.0.0, Thrift protocol 19.33.0 Very simple. Just enter this command in your cqlsh shell and enjoy select * from system.schema_keyspaces; In C*3.x, we can simply use describe keyspaces Peter Kipping Just try this: describe keyspaces However you may need specs of approximately the following (rather than those mentioned by yourself Crowie ) [cqlsh 4.1.1

Aggregation in Cassandra across partitions

烈酒焚心 提交于 2019-11-29 18:05:43
I have a Data model like below, CREATE TABLE appstat.nodedata ( nodeip text, timestamp timestamp, flashmode text, physicalusage int, readbw int, readiops int, totalcapacity int, writebw int, writeiops int, writelatency int, PRIMARY KEY (nodeip, timestamp) ) WITH CLUSTERING ORDER BY (timestamp DESC) where, nodeip - primary key and timestamp - clustering key (Sorted by descinding oder to get the latest), Sample data in this table, SELECT * from nodedata WHERE nodeip = '172.30.56.60' LIMIT 2; nodeip | timestamp | flashmode | physicalusage | readbw | readiops | totalcapacity | writebw | writeiops

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

copy one table to another in cassandra

谁说胖子不能爱 提交于 2019-11-29 15:58:11
i want to copy data from standardevents to standardeventstemp.. below steps i am doing COPY events.standardevents (uuid, data, name, time, tracker, type, userid) TO 'temp.csv'; truncate standardevents; COPY event.standardeventstemp (uuid, data, name, time, tracker, type, userid) FROM 'temp.csv'; but i am getting below error after 3rd step Bad Request: Invalid STRING constant (3a1ccec0-ef77-11e3-9e56-22000ae3163a) for name of type uuid aborting import at column #0, previously inserted values are still present. can anybody explain the cause of this error and how can i resolve this datatype of

specify cqlsh output timezone

我与影子孤独终老i 提交于 2019-11-29 07:07:51
I have a table in cassandra with a datatype of timestamp. i am using cqlsh to get data out of the database and wanted to change the output format for how my timestamp column output looks like. I researched around and found that i can change the timestamp output format by making changes to the following file: ~/.cassandra/cqlshrc But i learnt that the only change i can make is the time elements, i cannot make the output to display my timestamps in a different timezone(say UTC). It always displays the timestamps in my local timezone. I wanted to know if there is a way i could make cqlsh display

Inserting a hard-coded UUID via CQLsh (Cassandra)

冷暖自知 提交于 2019-11-29 05:24:00
Would like to populate some static test data via a CQLsh script. This doesn't work: (device_id is UUID) insert into devices (device_id, geohash,name, external_identifier, measures, tags) values ('c37d661d-7e61-49ea-96a5-68c34e83db3a','9q9p3yyrn1', 'Acme1', '936', {'aparPower','actPower','actEnergy'},{'make':'Acme'}); Bad Request: Invalid STRING constant (c37d661d-7e61-49ea-96a5-68c34e83db3a) for device_id of type uuid I can't seem to find any CQL function to convert to proper type. Do I need to do this from a python script? Thanks, Chris You shouldn't put the quotes around the UUID to stop it

Cassandra UPDATE primary key value

前提是你 提交于 2019-11-29 01:33:28
I understand that this is not possible using an UPDATE. What I would like to do instead, is migrate all rows with say PK=0 to new rows where PK=1. Are there any simple ways of achieving this? For a relatively simple way, you could always do a quick COPY TO/FROM in cqlsh. Let's say that I have a column family (table) called "emp" for employees. CREATE TABLE stackoverflow.emp ( id int PRIMARY KEY, fname text, lname text, role text ) And for the purposes of this example, I have one row in it. aploetz@cqlsh:stackoverflow> SELECT * FROM emp; id | fname | lname | role ----+-------+-------+----------

Import and export schema in cassandra

会有一股神秘感。 提交于 2019-11-28 17:05:04
问题 How to import and export schema from Cassandra or Cassandra cqlsh prompt? 回答1: To export keyspace schema: cqlsh -e "DESC KEYSPACE user" > user_schema.cql To export entire database schema: cqlsh -e "DESC SCHEMA" > db_schema.cql To import schema open terminal at 'user_schema.cql' ('db_schema.cql') location (or you can specify the full path) and open cqlsh shell. Then use the following command to import keyspace schema: source 'user_schema.cql' To import full database schema: source 'db_schema

Cassandra partition key for time series data

浪子不回头ぞ 提交于 2019-11-28 12:41:23
I'm testing Cassandra as time series database. I create data model as below: CREATE KEYSPACE sm WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': 1 }; USE sm; CREATE TABLE newdata (timestamp timestamp, deviceid int, tagid int, decvalue decimal, alphavalue text, PRIMARY KEY (deviceid,tagid,timestamp)); In the Primary key, I set deviceid as the partition key which mean all data with same device id will write into one node (does it mean one machine or one partition. Each partition can have max 2 billion rows) also if I query data within the same node, the retrieval will be

How to copy data from a Cassandra table to another structure for better performance

柔情痞子 提交于 2019-11-28 12:03:22
In several places it's advised to design our Cassandra tables according to the queries we are going to perform on them. In this article by DataScale they state this: The truth is that having many similar tables with similar data is a good thing in Cassandra. Limit the primary key to exactly what you’ll be searching with. If you plan on searching the data with a similar, but different criteria, then make it a separate table. There is no drawback for having the same data stored differently. Duplication of data is your friend in Cassandra. [...] If you need to store the same piece of data in 14