Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with and query dynamic column families in Phantom for Cassandra?

I have recently started working with heavy and massive data which also needs to go through regular transaction.

Choosing Cassandra, my data model uses dynamic columns. I understand that with CQL one can alter tables and insert or query columns to get required data.

However, I was using Phantom client with Scala for Cassandra and reading through the documentation I could not find a way to write to or query from dynamic column families.

Given that we use case classes, how can one work with dynamic columns with Cassandra in Scala?

like image 650
chbh Avatar asked Oct 05 '15 08:10

chbh


1 Answers

I would suggest that you not dynamically alter table schemas as part of your data model. Cassandra is a row oriented database with partitioning and clustering of rows within partitions. So whatever you are trying to represent by adding or removing columns would be better handled by setting values in a fixed set of columns.

Although Cassandra allows table definitions to be altered to add and remove columns, this would normally be done only when adding a new feature to an application, so you would have an operator manually alter the schema, and then use modified application code to make use of the new schema.

I consider it dangerous for a client application to modify the schema by creating or altering tables since you run the risk of having multiple clients make changes at the same time.

like image 112
Jim Meyer Avatar answered Oct 05 '22 19:10

Jim Meyer