Chapter 9. Introduction to CQL 3 and Cassandra 1.2

Cassandra is a rapidly developing project. Massive improvements, features, supports, and extensions are added with every release. At the start of this book, Cassandra 1.1.x was the most stable version. At the time of writing this chapter, 1.2.x has been well matured and thoroughly tested. CQL is becoming a de facto Cassandra language, and Thrift API, although promised to be supported indefinitely, is dying slowly.

It is nice to see Cassandra from Thrift lenses, because it transparently shows what the underlying storage structure is. However, it requires lots of mind bending to get the picture. CQL on the other hand is feature laden, terse, and an SQL-like language. This chapter will generally dive into an informal introduction to CQL 3. We will see some of the most impacting features of Cassandra 1.2.x. It will also have some assorted topics remotely related to Cassandra.

CQL – the Cassandra Query Language

CQL is an SQL-like querying language for Cassandra. This book concentrates on Cassandra version 1.1.x, which is a sort of transition version from a querying perspective. It has Thrift API fully functional and well tested. It has CQL version 2, which does not give a lot of leverage against Thrift version. It also has CQL 3 beta version.

CQL 3 is a big step foward compared to Thrift or CQL 2. It has a lot of usability features and it is less verbose than Thrift. The main thing that distinguishes CQL 3 from the other two is it is the future. Thrift is not going to get abandoned, but it is not going to get any updates either. CQL 2 is likely to be removed. CQL 3 will be the most preferred way to interact with Cassandra going forward.

Note

You need to use CQL shell (cqlsh) to be able to execute CQL queries. In Cassandra 1.1.x, the default cqlsh console provides support to CQL 2. In order to use CQL 3 via cqlsh, use:

$CASSANDRA_HOME/bin/cqlsh -3

In all the places in this chapter, CQL refers to CQL 3. If there is a discussion about CQL 2, it is mentioned explicitly.

A little history on CQL:

Thrift RPC has been the primary way to communicate with Cassandra. But Thrift has a couple of issues, namely, being verbose and hard to digest for people migrating from SQL. CQL 2 was an effort to fix these issues and bring it closer to SQL. It had its own problems—wide-row insertion was unintuitive, client code needed to decompose the composite columns, count does not count columns but rows, and a few more issues. Ultimately, CQL 2 was just a good syntactic sugar for Thrift with some inefficiency. Cassandra 1.1 comes with CQL 3-beta that uses the learning from CQL 2. It is much easier than CQL 2, but if you are coming from a Thrift world, it may require a little learning to understand how CQL 3 represents the same underlying column family differently.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.78.136