{"record":{"id":"333cf58ecc6f90d1","repo":"apache/cassandra","slug":"modification-is-not-supported-by-table-metadat-333cf5","errorCode":null,"errorMessage":"Modification is not supported by table \" + metadata","messagePattern":"Modification is not supported by table \" \\+ metadata","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/virtual/CollectionVirtualTableAdapter.java","lineNumber":579,"sourceCode":"        return ((AbstractType<T>) type).decompose(value);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static <T> T compose(AbstractType<?> type, ByteBuffer value)\n    {\n        return (T) type.compose(value);\n    }\n\n    @Override\n    public TableMetadata metadata()\n    {\n        return metadata;\n    }\n\n    @Override\n    public void apply(PartitionUpdate update)\n    {\n        throw new InvalidRequestException(\"Modification is not supported by table \" + metadata);\n    }\n\n    @Override\n    public void truncate()\n    {\n        throw new InvalidRequestException(\"Truncate is not supported by table \" + metadata);\n    }\n}","sourceCodeStart":561,"sourceCodeEnd":587,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/virtual/CollectionVirtualTableAdapter.java#L561-L587","documentation":"Virtual tables in Cassandra are read-only system views exposed through the virtual table framework. CollectionVirtualTableAdapter.apply is the write hook, and it unconditionally rejects any modification attempt against the virtual table it adapts. This is intentional: virtual tables reflect live in-memory system state and cannot be written to.","triggerScenarios":"Executing any INSERT, UPDATE, DELETE, or BATCH statement that targets a virtual table (e.g. writing to system_views.* or a collection-backed virtual table). The CQL statement reaches VirtualTable.apply(PartitionUpdate) and immediately throws.","commonSituations":"Scripts or migration tools treating virtual tables like normal tables; typos in table names that resolve to a virtual table instead of a real one; automation that assumed system_views tables were writable.","solutions":["Do not write to virtual tables; they are read-only views over runtime state.","Check the table with `DESCRIBE TABLE` / query system_schema.virtual_tables to confirm it is virtual.","If you intended to change underlying state, modify the real configuration or feature that the virtual table exposes (e.g. nodetool, config in cassandra.yaml).","Fix any tooling/table-name typos that route writes to a virtual table."],"exampleFix":"// before\nINSERT INTO system_views.threads (thread_id, thread_name) VALUES (1, 'x');\n// after\nSELECT * FROM system_views.threads WHERE thread_name = 'x';","handlingStrategy":"validation","validationCode":"// CQL-side guard: confirm the table is not virtual before writing\nRow row = session.execute(\"SELECT kind FROM system_schema.tables WHERE keyspace_name=? AND table_name=?\", ks, table).one();\nif (row != null && \"virtual\".equals(row.getString(\"kind\")))\n    throw new IllegalStateException(table + \" is a virtual table and cannot be modified\");","typeGuard":null,"tryCatchPattern":"try { session.execute(writeStmt); }\ncatch (com.datastax.oss.driver.api.core.servererrors.InvalidQueryException e) {\n    if (e.getMessage().contains(\"Modification is not supported\")) { /* skip virtual table */ }\n    else throw e;\n}","preventionTips":["Check system_schema.virtual_tables / table kind before issuing writes.","Exclude virtual keyspaces (system_views, system_settings) from mutation tooling.","Treat all virtual tables as read-only in application code and ORMs."],"tags":["cassandra","virtual-table","read-only","cql"],"backgroundTag":"operation-not-supported","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}