Search in sources :

Example 1 with KeyspaceNotDefinedException

use of org.apache.cassandra.db.KeyspaceNotDefinedException in project cassandra by apache.

the class Schema method validateTable.

public TableMetadata validateTable(String keyspaceName, String tableName) {
    if (tableName.isEmpty())
        throw new InvalidRequestException("non-empty table is required");
    KeyspaceMetadata keyspace = keyspaces.getNullable(keyspaceName);
    if (keyspace == null)
        throw new KeyspaceNotDefinedException(format("keyspace %s does not exist", keyspaceName));
    TableMetadata metadata = keyspace.getTableOrViewNullable(tableName);
    if (metadata == null)
        throw new InvalidRequestException(format("table %s does not exist", tableName));
    return metadata;
}
Also used : KeyspaceNotDefinedException(org.apache.cassandra.db.KeyspaceNotDefinedException) InvalidRequestException(org.apache.cassandra.exceptions.InvalidRequestException)

Aggregations

KeyspaceNotDefinedException (org.apache.cassandra.db.KeyspaceNotDefinedException)1 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)1