Cassandra CQL idea

I have an idea but not sure it is good or not (i am not very familiar with rails internal architecture details yet).

Recently I got interested in Cassandra DB(“no sql” db). It has it’s uses.

( I am not in any way related to Cassandra team or Datastax)

And I thought, wouldn’t it be cool to use Cassandra in the same way we use other dbs supported by ActiveRecord.

Cassandra uses CQL language (Cassandra Query Language). CQL is similar to SQL with some additional features and some limitations.

I checked Arel gem. And it looks to me that it will not be hard to make it work with CQL as well. Some nodes should be added like TTL (time to live) - really nice feature of Cassandra. Other some nodes probably will do nothing in case of CQL.

So idea is next:

  • To add support of CQL in Arel. Probably joins are also possible but with two queries (probably in one cassandra batch?)

  • Make ActiveRecord to support Arel’s new features like ttl.

  • World is moving to using different databases for different purposes in the same project. So maybe it is not bad idea to make rails support SQL database and CQL database simultaneously?

I am not sure those are good ideas, so could you please share your thoughts about it?

If idea is good enough I can implement it (using cql-rb driver, arel, active_record).

Thank you

Would be awesome to see Arel working with a CQL dialect in addition to
SQL, even as an experiment.

Active Record assumes a lot about SQL and relational databases, so
adapting it is probably a longer shot. But very cool to try!

That sounds really interesting. From what I understand about AREL, (not a lot), you’d simply create a new visitor to translate the nodes into CQL, just like there’s a visitor to translate the nodes into dot for input into graphviz.

It’ll be sometime before I need this. I’m currently developing on Postgresql, but if scaling becomes an issue then AREL+CQL to Cassandra will be plan B for us.

I’ll be watching this thread with interest, and if I do need it I’ll chip in an help.

John Small