On one of my daily excursions into the data stream of twitter, I noticed I was included in an exchange with a Apache Cassandra user. He was venting his frustration about how cqlsh displayed tables after creation. When performing a ‘DESC table <table_name>’ he found it unclear how the underlying structure was arranged. To be specific, which part of the primary key was the partition key.
To this I replied
And his reply almost immediately was this
Ok then. Here is the link to the Jira: https://issues.apache.org/jira/browse/CASSANDRA-7274 Game on! I love it.
There was some discussion in the Jira about any objections. After a couple days to let people comment, I thought I would take a stab at making the change. I’ve written a lot of Java code in my day and it didn’t seem too daunting. I created a local branch of the 2.0.x code and dug in. As I started looking at how cqlsh actually displays the table string on a DESC command, I slowly realized this is all implemented in Python! I haven’t written a lot of Python code, but I know enough to be dangerous. It’s not like I’m flying a 747 for the first time. The worst thing that could happen is that I would be publicly shamed with my lame code. Ok. So worse.
You know the old saying: If at first you don’t succeed, erase any evidence you tried! With git reset on my side, I moved on. It didn’t take long, and I found the section of code responsible for adding parenthesis around partition keys when the number of keys is larger than one. Didn’t look difficult. With a couple of quick changes to the code, I think I had it. Using my new version of cqlsh, I created a few test tables and verified the correct output. Success!
Now it was just a matter of submitting the patch and waiting for the review. Two git commands create the patch for me:
git add bin/cqlsh
git diff –cached > 7274.txt
Now I have a patch file ready to attach to the original Jira. After you attach the file, you need to flag the Jira as ‘patch ready’ and a reviewer will come along and check it out. In my case, Aleksey Yeschenko reviewed and offered a further optimization. I made the change and re-uploaded the new patch. The next day Aleksey gave it a thumbs up and committed my change! (Proof: https://github.com/apache/cassandra/commit/6faf80c9d267ede53c139b5f2a39e8e56ee80b2a#diff-6469b081699ab92c53e0513a499ca5eb) That wasn’t too bad and even better, that simple suggestion is now a feature based on real user feedback.
I don’t always have the time to do this sort of thing, but I’m really glad I made the time. It was simple enough and got finished quickly. Instead of waiting on one of the core developers to pick it up sometime, I decided to do it myself. The result was just a little better user experience. I encourage anyone to try this and see how you can make things a little better. If I look at some products that call themselves open source, i feel like it’s a half truth when users can’t do this. Having an open Jira on Apache gives a lot of power to the community. Make sure you check it out sometime.