0
votes

I'm trying to dump the schema of a Cassandra keyspace that can be used to import it into another keyspace, for example to backup a cassandra keyspace and restore it into a different keyspace with the same schema.

I'm using cqlsh:

[cqlsh 2.3.0 | Cassandra 1.2.2 | CQL spec 3.0.1 | Thrift protocol 19.35.0]

I initially create the schema with a CLUSTERING ORDER timestamp DESCENDING order:

DROP KEYSPACE mailbox;

CREATE KEYSPACE mailbox 
    WITH REPLICATION  = { 'class': 'SimpleStrategy', 'replication_factor': '1' };

USE mailbox;

CREATE TABLE messages (
    id uuid,
    user_id uuid,
    contents varchar,
    created timestamp,

    PRIMARY KEY (id, created)
)
WITH CLUSTERING ORDER BY (created DESC);

Then I use the CQL function to dump what I thought would be valid CQL3:

cqlsh:mailbox> describe keyspace mailbox;

CREATE KEYSPACE mailbox WITH replication = {
  'class': 'SimpleStrategy',
  'replication_factor': '1'
};

USE mailbox;

CREATE TABLE messages (
  id uuid,
  created 'org.apache.cassandra.db.marshal.ReversedType'<timestamp>,
  contents text,
  user_id uuid,
  PRIMARY KEY (id, created)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

When I try to import that back into the cqlsh I get the following error:

Bad Request: line 3:56 mismatched input '<' expecting ')'
text could not be lexed at line 16, char 14

I believe it's failing to parse the created column definition (which was originally created with a CLUSTERING ORDER BY):

created 'org.apache.cassandra.db.marshal.ReversedType'<timestamp>

Is there some other method for dumping the schema of a given keyspace?

1

1 Answers

0
votes

Hm.. think this issue is resolved in cassandra 1.2.5 and you are using cassandra 1.2.2 https://issues.apache.org/jira/browse/CASSANDRA-5528 and better yet, upgrade to cassandra 2.0 because tested here, it works fine in cassandra 2.0.2.

As a side note, you may also want to keep an eye on cql version. http://cassandra.apache.org/doc/cql3/CQL.html#Versioning