Search code examples
debuggingautocompletecassandracqlsh

How to debug cqlsh?


I need to find out how cqlsh does the autocomplete because I want to include a custom compaction strategy in the autocomplete for the create table statement. I usually do this by putting a breakpoint somewhere in the code and then following the flow. But I'm not sure how to do this with cqlsh since I don't see the main method. How can I debug cqlsh to better understand where I need to implement this? Probably not relevant, but I'm using v3.11.


Solution

  • Cqlsh is a python tool, It located at $CASSANDRA_HOME/bin/cqlsh.py

    If you want to add custom compaction strategy to cqlsh, you have to edit it's dependency file located at $CASSANDRA_HOME//pylib/cqlshlib/cqlhandling.py

    Find the available_compaction_classes field and add yours.

    available_compaction_classes = (
        'LeveledCompactionStrategy',
        'SizeTieredCompactionStrategy',
        'DateTieredCompactionStrategy',
        'TimeWindowCompactionStrategy',
        'MyCompactionStrategy'
    )
    

    Here i have added MyCompactionStrategy.

    Now save the changes and relogin, you will get autocomplete for compaction

    cassandra@cqlsh:titan> CREATE TABLE test (id int primary key, data text) WITH compaction = {'class': '
    DateTieredCompactionStrategy  LeveledCompactionStrategy     MyCompactionStrategy          SizeTieredCompactionStrategy  TimeWindowCompactionStrategy