apache/cassandra · error · InvalidRequestException

Truncation is not supported by table " + metadata

Error message

Truncation is not supported by table " + metadata

What it means

AbstractVirtualTable's default truncate() implementation rejects TRUNCATE statements. Virtual tables hold computed, in-memory data rather than durable SSTables, so truncation has no meaning and is rejected with InvalidRequestException.

Source

Thrown at src/java/org/apache/cassandra/db/virtual/AbstractVirtualTable.java:136

            @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("Truncation is not supported by table " + metadata);
    }

    @Override
    public String toString()
    {
        return metadata().toString();
    }

    public interface DataSet
    {
        boolean isEmpty();
        Partition getPartition(DecoratedKey partitionKey);
        Iterator<Partition> getPartitions(DataRange range);
    }

    public interface Partition
    {
        DecoratedKey key();

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Do not truncate virtual tables; simply SELECT from them — data is ephemeral and recomputed on each read.
  2. If the goal is dropping accumulated state, restart the node or use the specific admin operation that clears the underlying component.
  3. If implementing a custom virtual table, override truncate() if clearing internal state makes sense.
  4. Exclude tables with TableMetadata.VIRTUAL from truncation lists in scripts.

Example fix

// before
session.execute("TRUNCATE system_views.clients");
// after
// read-only: no truncate needed
ResultSet rs = session.execute("SELECT * FROM system_views.clients");
Defensive patterns

Strategy: validation

Validate before calling

if (sql.trim().toUpperCase().startsWith("TRUNCATE")) { /* verify target is not a virtual table */ }

Type guard

boolean isTruncatable(TableMetadata m) { return !m.virtual; }

Try / catch

try { session.execute(truncate); } catch (com.datastax.driver.core.exceptions.InvalidQueryException e) { if (e.getMessage().contains("Truncation is not supported")) { /* skip; virtual table */ } else throw e; }

Prevention

When it happens

Trigger: Running 'TRUNCATE <virtual_table>' (e.g. TRUNCATE system_views.clients) against any virtual table whose class does not override truncate().

Common situations: Cleanup scripts that blindly truncate tables found in system_schema; test harnesses resetting system tables between runs; DBAs trying to clear large virtual table result sets.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/66386f65a6867636. Report an issue: GitHub.