i try to make composite primary key using cassandr-CLI but i'm unable to do that, i am able to do that using Cqlsh.
can you help me out?
This seems to be addressed in other questions:
Create two composite columns with cassandra-cli
create Composite-keyed Table with cassandra-cli
The constructor CompositeType(keyelem1_type, keyelem2_type, keyelem3_type) should be used in cassandra-cli. Example (from this website providing good overview on composite keys in CQL and cassandra-cli - http://itsallabtamil.blogspot.com/2012/10/cassandra-compositetype-overview-cql.html):
create column family TestComposite
with comparator='CompositeType(UTF8Type, UTF8Type, LongType)'
and key_validation_class = 'UTF8Type',
and defaut_validation_class = 'UTF8Type';
HTH.
Related
With Kentico 13, I'm looking for a way to specify the primary key value when inserting a TreeNode via API. Something like:
var node = TreeNode.New("MyPageType");
node.SetValue("MyPageTypeID", 1234);
node.Insert(parentNode);
This needs to set the primary key in the MyPageType table so needs SQL identity insert on, and also needs to set the DocumentForeignKeyValue in the CMS_Document table.
The only way I have thought of doing it is with some custom SQL after the node is created, but feels like a hack. Is there a better way?
This is for a content migration task of thousands of documents. After the content migration the default SQL & primary key behavior will be used.
In case anyone finds this, the solution I came up with was to run the content migration script with the old primary key value in a temporary column. After migration I ran SQL to update Kentico references to the old primary key, remove the old primary key, and change the primary key to the temporary column. A bit nasty, but got the job done.
We are designing table in cassandra which has the following schema :-
customeruuid,assetuuid,activation_status,createdtime
PK(customeruuid,assetuuid)
We need to support searching usecase where we need to list all assetuuid for particular customer with where clause on activation_status column.There could be millions of assets for customer.I did research on web and found that we could create an materialized view over this table. I am trying it out using following cql:
CREATE MATERIALIZED VIEW myiew1 AS SELECT customeruuid,agentuuid,activation_status
FROM temp WHERE customeruuid IS NOT NULL AND
agentuuid IS NOT NULL PRIMARY KEY ( customeruuid, agentuuid );
I wanted to include where clause on activaiton_status column in select query but I am not able to do it. Does latest versions of cassandra supports such kind of operation or Do we have other alternative to solve this problem maybe by changing data modelling?
When I tried to retrieve table using contains keyword it prompts "Cannot use CONTAINS relation on non collection column col1" but when I tried to create table using
CREATE TABLE test (id int,address map<text, int>,mail list<text>,phone set<int>,primary key (id,address,mail,phone));
it prompts "Invalid collection type for PRIMARY KEY component phone"
One of the basics in Cassandra is that you can't modify primary keys. Always keep that in mind.
You can't use a collection as primary key unless it is frozen, meaning you can't modify it.
This will work
CREATE TABLE test (id int,address frozen<map<text, int>>,mail frozen<list<text>>,phone frozen<set<int>>,primary key (id,address,mail,phone));;
However, I think you should take a look at this document: http://www.datastax.com/dev/blog/cql-in-2-1
You can put secondary indexes on collections after cql 2.1. You may want to use that functionality.
I am not able to create collection inside another collection in Cassandra. Please find error details below
cqlsh:TestKeyspace> create table users2(user_id text primary key, feeschedule map<text,set<text>>);
Bad Request: map type cannot contain another collection
Here I am trying to create column named feeschedule with type Map and Map have values which is of type List.
Could anybody suggest me how do I achieve it in Cassandra.
My Cassandra version details are given below:
cqlsh version- cqlsh 4.1.0
Cassandra version – 2.0.2
Thanks in advance,
You are correct, nested collections are not supported.
You will be able to do something similar with user-defined types, but not until 2.1: https://issues.apache.org/jira/browse/CASSANDRA-5590
I'm currently trying to figure out whether I can access composite columns in Cassandra without using the AnnotatedCompositeSerializer. I'm looking for a method similar to what Hector does, using the Composite class and adding components.
I have search in Google but wasn't able to find any hints except for the AnnotatedCompositeSerializer. I want to use the composite key as a row key by the way.
Any hints on where to look next?
Take a look at the PrefixedSerializer from the wiki page.