Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to discover Cassandra CQL table structure?

Tags:

cassandra

cql

Let's say I use CQL to define this table.

CREATE TABLE songs (
    id uuid PRIMARY KEY, 
    title text,
    album text, 
    artist text, 
    tags set<text>, 
    data blob);

How can other developers (or myself after a few weeks) (re)discover the layout of this table?

I'm thinking of an equivalent to the MySQL DESCRIBE {tablename} command.

[EDIT]

I see there is a DESCRIBE method in Cassandra's command line interface (CLI), but upon using it, it states that it doesn't include information on CQL tables in its results.

like image 733
Vinnie Avatar asked Aug 07 '13 14:08

Vinnie


People also ask

How do I find my Keyspace in Cassandra?

Go to data tab > there you will see all keyspcaces created by you and some system keyspaces. You can see all tables under individual keyspaces and also replicator factor for keyspace.

How do I find out the size of a table in Cassandra?

If you need to know informaiton about table or tables you can use Nodetool cfstats command. Syntax: If you will only provide the name of keyspace, it will provide stats for all the tables in that keyspace.

Which command would you use to describe your Cassandra table?

$describe = new Cassandra\SimpleStatement(<<<EOD describe keyspace. tablename EOD ); $session->execute($describe);


2 Answers

You should try the cqlsh tool which will show you exactly what you want:

lyubent@vm: ~$ ./cqlsh 
cqlsh> use system;
cqlsh> describe columnfamily local;

CREATE TABLE local (
  key text PRIMARY KEY,
  bootstrapped text,
  cluster_name text,
  cql_version text,
  data_center text,
  gossip_generation int,
  host_id uuid,
  partitioner text,
  rack text,
  release_version text,
  schema_version uuid,
  thrift_version text,
  tokens set<text>,
  truncated_at map<uuid, blob>
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='information about the local node' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=0 AND
  read_repair_chance=0.000000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

EDIT
Although great at the time the blog i linked is ood. To run cqlsh in windows:

  • first install python 2.7.x (not python 3!) download
  • Add python to your path (as a new environment variable)
  • Run the setup by navigating to C:\dir\to\cassandra\pylib in a cmd prompt and executing the below line:

    python setup.py install
    

GZ. Now you have cqlsh on windows.

like image 86
Lyuben Todorov Avatar answered Sep 19 '22 08:09

Lyuben Todorov


It can also be done with DevCenter and OpsCenter.

DevCenter: Find the table in Schema -> right click -> clone table. You can find CQL Preview at the button of the window.

OpsCenter: Cluster -> Data -> Table

like image 36
treehouse Avatar answered Sep 21 '22 08:09

treehouse