apache/cassandra · error · InvalidRequestException
non-empty table is required
Error message
non-empty table is required
What it means
SchemaProvider.validateTable rejects an empty table name with InvalidRequestException('non-empty table is required') before any keyspace lookup. The API requires a concrete, non-empty table identifier to resolve metadata.
Solutions
- Pass a valid, non-empty table name to the statement or API call.
- Fix upstream statement parsing/templating so the table name is populated.
- Add a client-side check that the table name is non-empty before issuing the operation.
Example fix
// before
TableMetadata tm = schema.validateTable(keyspace, tableName); // tableName == ""
// after
if (tableName == null || tableName.isEmpty()) throw new IllegalArgumentException("table name required");
TableMetadata tm = schema.validateTable(keyspace, tableName); Defensive patterns
Strategy: validation
Validate before calling
if (tableName == null || tableName.isEmpty())
throw new IllegalArgumentException("Table name must be a non-empty string");
if (!tableName.matches("\\w+"))
throw new IllegalArgumentException("Table name contains illegal characters: " + tableName); Type guard
boolean isValidTableName(String name) {
return name != null && !name.isEmpty() && name.matches("[a-zA-Z_][a-zA-Z0-9_]*");
} Prevention
- Validate statement templates so table-name placeholders are always substituted.
- Fail fast in application code when a table name variable is null/empty.
- Add unit tests covering statement construction with missing table identifiers.
When it happens
Trigger: Calling validateTable (directly or via query processing paths that resolve a statement's table) with tableName == "" — e.g. a parsed statement whose table name defaulted to empty, or programmatic callers passing an empty string.
Common situations: Statement parsing bugs building empty table names; internal tooling or drivers invoking metadata APIs with unset table variables; templated queries where the table placeholder was not substituted.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Can only unset '" + name + "'
- Invalid tuple literal for
- message (caller-provided message string)
- messageTemplate (caller-provided message template, 1 arg)
- messageTemplate (caller-provided message template, 2 args)
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/99f4e319d7f71990.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/schema/SchemaProvider.java:98
return getTableMetadata(descriptor.ksname, descriptor.cfname).ref;
}
default ViewMetadata getView(String keyspaceName, String viewName)
{
assert keyspaceName != null;
KeyspaceMetadata ksm = distributedKeyspaces().getNullable(keyspaceName);
return (ksm == null) ? null : ksm.views.getNullable(viewName);
}
default Keyspaces getNonLocalStrategyKeyspaces()
{
return distributedKeyspaces().filter(keyspace -> keyspace.params.replication.klass != LocalStrategy.class);
}
default TableMetadata validateTable(String keyspaceName, String tableName)
{
if (tableName.isEmpty())
throw new InvalidRequestException("non-empty table is required");
KeyspaceMetadata keyspace = getKeyspaceMetadata(keyspaceName);
if (keyspace == null)
throw new KeyspaceNotDefinedException(String.format("keyspace %s does not exist", keyspaceName));
TableMetadata metadata = keyspace.getTableOrViewNullable(tableName);
if (metadata == null)
throw new InvalidRequestException(String.format("table %s does not exist", tableName));
return metadata;
}
default ColumnFamilyStore getColumnFamilyStoreInstance(TableId id)
{
TableMetadata metadata = getTableMetadata(id);
if (metadata == null)
return null;
View on GitHub (pinned to 88fd0f6a0e)