Cassandra Scala drivers

Hi there! After a long time of laziness I came back to write something about what I’ve done during this time of absence apart from my holidays. And BTW happy new year!

In the last year I’ve been working quite a lot with Cassandra, always using the official Java Driver supported by DataStax, the company behind the database. And I remember that I’ve searched before for a Scala driver and reactive if it was possible and I found only one but not very good to me at that moment. The thing is during this week I was challenged to create a program to basically query some of our Cassandra tables by exposing a REST API, so I started looking for a cool Scala driver.


Starting by simply type “scala cassandra driver” in Google these are the first four results:

First a reactive type-safe driver, second a Scala wrapper of the official Java driver, third the official web site driver list and last a Stack Overflow topic about it.


So I decided to give Phantom a chance because it has a high activity on GitHub, it is an open source driver and I think the DSL is pretty good. However I found a few problems trying to start working with; a basic thing like getting a connection to the database using username/password authentication is not supported by the DSL. And after research for a while I found that a lot of good features are only present in the commercial version.

That’s why after getting the problem mentioned above I kept searching for more Scala drivers and summing up this is the list:

  • scala-cassandra: just a wrapper around the official Java driver. Last activity on GitHub 2 years ago.
  • cascal: one of the drivers mentioned in the official DataStax driver list apart from Phantom. Last activity on GitHub 3 years ago.
  • cassie: developed by Twitter. Last activity on GitHub 3 years ago.
  • scqla: lack of design, no DSL. Last activity on GitHub 2 years ago.

As you can see all of this projects are no longer maintained, so once again I came back to Phantom trying to make it work.


After a few hours trying to get a connection using Phantom, including opening an issue (hopefully I’ll get a response soon), I created a project to share my workaround solution which I called phantom-ssl-extension, mainly intended to work with Java 8.

It consists on the creation of a CustomSessionProvider mixing Phantom with the official Java driver and a few util functions. I invite you to check the example out in order to see how it works and I hope you had enjoyed this short research post.

Until next time!



  1. Flávio Brasil · January 27, 2016

    You could try the new quill-cassandra module:


    • Gabriel Volpe · January 27, 2016

      Thanks Flavio, I was trying it out this morning. The DSL looks astonishing but I couldn’t find a way to set up an SSL connection like I did here. Why did you decide to setup the connection by using reflection? I found the ClusterBuilder that is doing this when the session is created.

      Liked by 1 person

      • Flávio Brasil · February 20, 2016

        We’ve release a new version of Quill with a more flexible configuration mechanism. You can override the cluster creation:

        import io.getquill._
        import io.getquill.naming.SnakeCase

        lazy val db = source(new CassandraAsyncSourceConfig[SnakeCase](“db”)) {
        override def builder = {
        val b = super.builder
        // customize b

        Please feel free to reach out to me on gitter ( if you have troubles trying to use it.


  2. Gabriel Volpe · February 4, 2016

    In this post I’m talking about Cassandra Scala drivers and not about integration with other technologies like Spark. So I think it is irrelevant, more after seeing that you need a SparkConf instance in order to get a connection to Cassandra which should be totally independent.


    • Gwanggaeto · February 4, 2016

      Your reply makes not sense at all. Not surprised, though, since you clearly have not real world experience.


      • Gabriel Volpe · February 4, 2016

        I think it makes a lot of sense. Why should I use Spark to get a connection to Cassandra when I don’t need it? But given the case that we have an expert here with decades of “real world experience” and it seems he also knows about me, maybe I’m wrong and I need to bring Spark to the context.

        PS: If you’re going to make any other pointless comment, please get a “real world name” first, thank you.


      • Gwanggaeto · February 4, 2016

        Naturally, you don’t need to connect from a Spark context to Cassandra. Alternatives do exist. But at what cost? Do you not understand the power of data / processing locality?


      • Gabriel Volpe · February 4, 2016

        It would be nice if you could support your comments with some source. Anyway if it’s possible I’ll ask you the same question I asked Flavio (comments above). How can I create an SSL connection to Cassandra like I did here using this library? Thanks.


  3. Jan · May 9, 2016

    Gabriel, did you look for Quill? As a C# dev I liked the Linq-like approach.


    • Gabriel Volpe · May 9, 2016

      Yes, I did a few months ago. As I said before in the comments, the DSL is really good but I found some problems creating SSL connections and some issues with the encoders. I know the community is really active and this issues are maybe fixed now but I needed to release a production version last January. For sure I’d give it a try again if I have a similar task!


  4. vejeta · September 19, 2016

    Just a note, Phantom is not Free Software/Open Source:


  5. Flavian · February 17, 2017

    Hey just a note on Phantom, there is no special module or configuration required for username or password authentication and you’re implying you need a commercial license which is not the case. This functionality has been around in phantom for a very long time using ClusterBuilder, and phantom-connectors merely wrap that.

    I want to make sure people Googling for this are able to find the best and most up to date information on phantom and it would be good if they had the means to understand how not a lot of special setup is required to achieve this.

    import com.datastax.driver.core.PlainTextAuthProvider

    lazy val local = ContactPoint.local.withClusterBuilder(
    _.withAuthProvider(new PlainTextAuthProvider(“user”, “pass”))


    • Gabriel Volpe · February 18, 2017

      Thanks for the update Flavian. When this post was written I found a couple of problems with the authenticated connection that is described in it. I also submitted this issue: but glad to hear that it is now working that easily. Cheers!


      • Flavian · February 26, 2017

        Hey, you can simply turn off the autocreation behaviour by setting `autoinit` to false, a flag which you can now pass. It’s also possible to create advanced keyspace inialisation queries and pass them through as well, so you can do pretty much whatever you like, these issues have been long addressed.

        Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s