cassandrahectornosql

Retrieve all the columnfamily / tables of thrift and CQL from the keyspace in cassandra


I use hector to manipulate cassandra of version 2.1.8 and want to retrieve all the tables from certain keyspace in an application. I use "KeyspaceDefinition.getCfDefs()" to retrieve the columnfamily list in a keyspace.

However, I found that the getCfDefs() function can just retrieve the columnfamily created by the thrift api such as "me.prettyprint.hector.api.Cluster.updateColumnFamily" but not table created by CQL such as cqlsh client.

Then, how to retrieve all the tables from certain keyspace by using hector?


Solution

  • You can inspect all table metadata for a keyspace programmatically using the system metadata tables:

    select * from system.schema_columnfamilies where keyspace_name='ks';
    select * from system.schema_columns where keyspace_name='ks';
    

    You would need to aggregate these columns and tables yourself.

    Alternatively, if you're not tied to this client, you can use cqlsh to "describe" the keyspace in question, or use one of the DataStax drivers with a metadata API (java, python).