Search code examples
cassandracqlcql3cqlsh

Unknown property 'compaction_strategy_class' with cql 3 and cassandra 2.0.1


Using this configuration of cassandra:

Connected to Test Cluster at localhost:9161.
[cqlsh 4.0.1 | Cassandra 2.0.1 | CQL spec 3.1.1 | Thrift protocol 19.37.0]

When I tried to do:

ALTER TABLE snpSearch WITH compaction_strategy_class='SizeTieredCompactionStrategy'

I obtain this error:

Bad Request: Unknown property 'compaction_strategy_class'

I know that SizeTieredCompactionStrategy is the default strategy, but i want also to modify the sstables size and this:

ALTER TABLE snpSearch WITH compaction_strategy_class='SizeTieredCompactionStrategy' AND  compaction_strategy_options:sstable_size_in_mb:10;

give me this error:

Bad Request: line 1:116 mismatched input ':' expecting '='

I read the cql documentation and should be correct, does anyone know what could be the problem?

Thanks


Solution

  • The correct format is:

    ALTER TABLE snpSearch WITH compaction={'class':'SizeTieredCompactionStrategy'};
    

    The format for WITH options of the ALTER command is described here. The important part is:

    [...] The supported (and syntax) are the same as for the CREATE TABLE statement [...]

    And the example from the CQL3.1 documentation shows how the compaction and compression strategies can be set.

    ( Tested on [cqlsh 4.0.1 | Cassandra 2.0.1 | CQL spec 3.1.1 | Thrift protocol 19.37.0].)