javacassandracassandra-3.0cassandra-2.0datastax-java-driver

how do I check if a column exists in cassandra table in java?


I want to check if a column exists in cassandra table in java,and then perform an action if it exists.How do I do that?


Solution

  • You can get table definition via Metadata class. Something like:

    Column column = cluster.getMetadata().getKeyspace("ks-name")
       .getTable("table-name").getColumn("column-name");
    if (column != null) {
       // do your stuff
    }