I am trying to fetch the Primary Key/Clustering Key names for a particular table/entity and implement the same query in my JPA interface (which extends CassandraRepository). I am not sure whether something like:
@Query("DESCRIBE TABLE <table_name>)
public Object describeTbl();
would work here as describe
isn't a valid CQL statement and in case it would, what would be the type of the Object
?
Suggestions?
One thing you could try, would be to query the system_schema.columns
table. It is keyed by keyspace_name
and table_name
, and might be what you're looking for here:
> SELECT column_name,kind FROM system_schema.columns
WHERE keyspace_name='spaceflight_data'
AND table_name='astronauts_by_group';
column_name | kind
-------------------+---------------
flights | regular
group | partition_key
name | clustering
spaceflight_hours | clustering
(4 rows)