apache/cassandra · error · InvalidRequestException
Truncate is not supported by table
Error message
Truncate is not supported by table
What it means
CollectionVirtualTableAdapter.truncate rejects TRUNCATE statements against virtual tables. Virtual tables hold ephemeral runtime data derived from the node, so truncation is meaningless and unsupported; the framework throws InvalidRequestException unconditionally.
Source
Thrown at src/java/org/apache/cassandra/db/virtual/CollectionVirtualTableAdapter.java:585
return (T) type.compose(value);
}
@Override
public TableMetadata metadata()
{
return metadata;
}
@Override
public void apply(PartitionUpdate update)
{
throw new InvalidRequestException("Modification is not supported by table " + metadata);
}
@Override
public void truncate()
{
throw new InvalidRequestException("Truncate is not supported by table " + metadata);
}
}View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Remove the TRUNCATE statement; virtual table contents cannot and need not be cleared.
- If state needs resetting, restart the node or change the underlying runtime setting the table mirrors.
- Verify the target keyspace is not a virtual keyspace (system_views, system_settings, etc.) before running maintenance scripts.
Example fix
// before TRUNCATE system_views.threads; // after SELECT * FROM system_views.threads; // read-only; no truncation possible
Defensive patterns
Strategy: validation
Validate before calling
// skip TRUNCATE for virtual tables
List<Row> virtual = session.execute("SELECT keyspace_name, table_name FROM system_schema.virtual_tables").all();
Set<String> vt = virtual.stream().map(r -> r.getString("keyspace_name")+"."+r.getString("table_name")).collect(Collectors.toSet());
if (vt.contains(ks + "." + table)) return; // do not truncate Try / catch
try { session.execute("TRUNCATE " + ks + "." + table); }
catch (com.datastax.oss.driver.api.core.servererrors.InvalidQueryException e) {
if (e.getMessage().contains("Truncate is not supported")) { /* ignore: virtual table */ }
else throw e;
} Prevention
- Filter virtual keyspaces out of cleanup/truncate scripts.
- Never blanket-truncate system* keyspaces.
- Remember virtual table data is ephemeral node state; truncation is never needed.
When it happens
Trigger: Running `TRUNCATE <virtual_keyspace>.<virtual_table>;` (or a DROP-style data-clearing call) on any virtual table, e.g. system_views or system_settings tables.
Common situations: Cleanup scripts that blanket-truncate tables in system keyspaces; test fixtures resetting 'system' tables; misunderstanding that virtual tables persist data.
Related errors
- Truncation is not supported by table " + metadata
- The specified table is read-only.
- Truncation is not supported by table %s
- Modification is not supported by table " + metadata
- Modification is not supported by table " + metadata
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4986aba7373647c3.
Report an issue: GitHub.