Skip to content

Instantly share code, notes, and snippets.

@tabdulradi
Last active November 15, 2016 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tabdulradi/1a8e8cd5a4132853f40683e114b0ad3a to your computer and use it in GitHub Desktop.
Save tabdulradi/1a8e8cd5a4132853f40683e114b0ad3a to your computer and use it in GitHub Desktop.
Troy Abstract

Introducing Troy: The schema-safe Cassandra toolkit.

Troy is an open source macro-based Cassandra driver, similar to Slick and Quill, provides type-safe & compile-time checking for database queries. Nevertheless, it doesn't impose a DSL to express the queries in Scala. Instead, it allows developers to write plain Cassandra-query-language (CQL) queries within Scala code, complete with schema validation. In addition, it provides cross-validation against the previous versions, ensuring safe and smooth schema migrations.

It is worth noting that Troy doesn't connect to Cassandra during compilation. Instead, the schema is provided as CQL scripts, checked-in within same code base, consisting of plain CREATE TABLE CQL statements. That get's loaded at compile-time into a light-weight Schema engine capable of analysing queries and providing information about column types. Those CQL scripts can be written as increments, by adding new scripts containing ALTER TABLE statement, instead of editing existing scripts. This allows Troy to check backwards and forward compatibility of queries against different versions of the schema. As well as providing tools to write migration scripts.

Currently, Troy uses reflection-based black-box macros. But also has a working proof-of-concept using the new style inline/meta as well.

In this talk, I will be presenting slides and code, with live coding examples.

Introducing Troy: Schema-safe Cassandra client

By: Tamer Abdul-Radi

Abstract

TODO

Motivation

As a Cassandra developer, I find myself using cqlsh while designing my schema to validate my queries. When I start writing my scala app, I already have the CQL

I find it easier to think about queries in terms of CQL than alternative formulations. However, using plain CQL might introduce an error when changing code.

On the other hand, using other formulations to write queries as Scala code, then generate the CQL from it (like Quill), might be limiting in specific cornercases when I want to write an advanced query. Plus it is not readable

So I decided to write a Cassandra driver that allows me to use Plain CQL, but still validate the correctness of the query against the schema.

Problem Analysis

Proposed Solution

Implementation

code example

Features

Query Validations

???

???

Auto-Parsing (Codecs)

???

Compatibility

???

Schema Migrations

Design considerations

Whitebox Macro

TODO

Conclusion

TODO

Feedback

TODO

References

  1. Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment