What query to issue to extract only column names(no values)? - cassandra

RangeSliceQuery has a convenient method to extract only the keys - setReturnKeysOnly() but I couldn't find something similar in SliceQuery (like setReturnColumnNamesOnly()).
Is this functionality provided somewhere in Hector API?

If you want get only column names belonging to a particular column family, i can show you a way how you can achieve it using cql
select * from system.schema_columns WHERE keyspace_name='#KS' AND columnfamily_name='#CF' allow filtering;
Now i don't think it will be great technical hurdle to achieve the same thing using your hector api.
Cheers

Related

IBM Cognos: matching multiple columns (two foreign keys)

I am learning how to use IBM Cognos and my first task is to create relationships between the tables I have uploaded into Cognos.
Basically, I am trying to tell Cognos to link the id column in the Person Table with the person_id and related_person_id columns in the Relationship Table, as shown here:
However, this does not seem possible since the Match Selected Columns button becomes disabled when I try to also link the related_person_id column.
The reason I need to do this is because person_id and related_person_id are foreign keys - they point to people in the Person Table and explain how they are related.
How can this be accomplished in Cognos?
Thank you.
You can have any number of matches. You need to match a single query item from each side for each match. IIRC, a query item can be used in multiple matches, although that would only be really helpful once relational operators are implemented.
It isn't clear if in your case you want to use person_id and related_person_id as a composite key or if you want a 1.n relationship between ID and person_id and some other relationship (n.1?) between ID and related person ID or if a 1.n relationship between ID and person_id would be sufficient to whatever you are trying to accomplish.
Editorial comment:
It would be really really nice if Cognos introduced relational operators Real Soon Now.

Presto map(varchar,varchar) : How to get all the possible keys for it?

I am trying to search a column having the data type map(varchar,varchar). Now one way to access the column is to use this structure, name_of_column['key'], which will give the value for that key. But I want to know what are possible keys and then apply group by and other operations based on those keys.
I tried searching on the internet but was not able to find appropriate solution.
Presto offers map_keys function for that:
presto> select map_keys(map(array['alice'], array['has a cat']));
_col0
---------
[alice]
(1 row)

How we can do CRUD operations on complex data models in Cassandra?

How we can do CRUD operations on complex data models in Cassandra?
I have a project using NOSQL.
I have a column family for my customers.
The column family has just "id" at first.
Then it will be updated by altering new columns.
Count and type of columns for each customer could be different.
Also, each column can include sub columns with ids again and it would be altered, too. So, they should be indexed. And documents are not useful for this issue.
I've read about NOSQL, and I've decided to use Cassandra. I will be thankful if you would answer this questions:
Is the above that possible?
How we can create and use CRUD operations on this column family?
If the answer of last question is true, what is the type of result of a query?
It will return some rows for each primary key (id)?
How we can manage that, to access a table like with no redundancy? because I don't now this summarizing should be manage in DBside or in code side.
Thank you for your help.

how to implement fixed number of (timeuuid) columns in cassandra (with CQL)?

Here is an example use case:
You need to store last N (let's say 1000 as fixed bucket size) user actions with all details in timeuuid based columns.
Normally, each users' actions are already in "UserAction" column family where user id as row key, and actions in timeuuid columns. You may also have "AllActions" column family which stores all actions with same timeuuid as column name and user id as column value. It's basically a relationship column family but unfortunately without any details of user actions. Querying with this column family is expensive I guess, because of random partioner. On the other hand, if you store all details in "AllActions" CF then cassandra can't handle that big row properly at one point. This is why I want to store last N user actions with all details in fixed number of timeuuid based columns.
Maybe you may have a better design solution for this use case... I like to hear that ...
If not, the question is how to implement fixed number of (timeuuid) columns in cassandra (with CQL) effectively?
After insertion we could delete old (overflow) columns if we had some sort of range support in cql's DELETE. AFAIK there is no support for this.
So, any idea? Thanks in advance...
IMHO, this is something that C* must handle itself like compaction. It's not a good idea to handle this on client side.
Maybe, we need some configuration (storage) options for column families to make them suitable for "most recent data".

Complex Queries in Cassandra

How can I make complex queries in Cassandra?
As example, I have a set of objects with id, name and others properties, and I want all Ids with the name starting with some string.
Is that possible?
Thanks,
Unfortunately, order preserving partition is not the ideal solution. What if you want to do range query base on some column value. Moreover, partitioning scheme selected applies to a whole Cassandra instance, and not individual keyspace.
You have to roll out your own index. Check my post on this topic
http://pkghosh.wordpress.com/2011/03/02/cassandra-secondary-index-patterns/
Pranab
yes, thats plausible. use range queries and order preserving partitioner. (read bens excellent slides about index and range queries)

Resources