{"record":{"id":"6c61153c7f80f6a3","repo":"apache/cassandra","slug":"static-columns-are-not-supported-in-compact-storag","errorCode":null,"errorMessage":"Static columns are not supported in COMPACT STORAGE tables","messagePattern":"Static columns are not supported in COMPACT STORAGE tables","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java","lineNumber":438,"sourceCode":"                if (staticColumns.contains(column))\n                    builder.addStaticColumn(column, properties.type, properties.mask, columnConstraints.get(column));\n                else\n                    builder.addRegularColumn(column, properties.type, properties.mask, columnConstraints.get(column));\n            });\n        }\n\n        return builder;\n    }\n\n    private void validateCompactTable(List<ColumnProperties> clusteringColumnProperties,\n                                      Map<ColumnIdentifier, ColumnProperties> columns)\n    {\n        boolean isDense = !clusteringColumnProperties.isEmpty();\n\n        if (columns.values().stream().anyMatch(c -> c.type.isMultiCell()))\n            throw ire(\"Non-frozen collections and UDTs are not supported with COMPACT STORAGE\");\n        if (!staticColumns.isEmpty())\n            throw ire(\"Static columns are not supported in COMPACT STORAGE tables\");\n\n        if (clusteringColumnProperties.isEmpty())\n        {\n            // It's a thrift \"static CF\" so there should be some columns definition\n            if (columns.isEmpty())\n                throw ire(\"No definition found that is not part of the PRIMARY KEY\");\n        }\n\n        if (isDense)\n        {\n            // We can have no columns (only the PK), but we can't have more than one.\n            if (columns.size() > 1)\n                throw ire(String.format(\"COMPACT STORAGE with composite PRIMARY KEY allows no more than one column not part of the PRIMARY KEY (got: %s)\", StringUtils.join(columns.keySet(), \", \")));\n        }\n        else\n        {\n            // we are in the \"static\" case, so we need at least one column defined. For non-compact however, having\n            // just the PK is fine.","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java#L420-L456","documentation":"Static columns are not supported in COMPACT STORAGE tables because the legacy Thrift storage format has no representation for per-partition static cells. The validator throws this error whenever any declared column is static in a compact table.","triggerScenarios":"CREATE TABLE ... WITH COMPACT STORAGE with a column declared STATIC.","commonSituations":"Adding STATIC columns to a legacy compact table; copying a regular table definition and appending COMPACT STORAGE.","solutions":["Remove the STATIC keyword (and possibly the column) from the compact table.","Drop COMPACT STORAGE so static columns are allowed."],"exampleFix":"// before\nCREATE TABLE t (pk int, c int, v text STATIC, PRIMARY KEY (pk, c)) WITH COMPACT STORAGE;\n// after\nCREATE TABLE t (pk int, c int, v text, PRIMARY KEY (pk, c)) WITH COMPACT STORAGE;","handlingStrategy":"validation","validationCode":"// STATIC columns are forbidden in COMPACT STORAGE tables:\nboolean compactStorage = true;\nboolean hasStatic = false; // any STATIC column declared\nif (compactStorage && hasStatic) throw new IllegalArgumentException(\"STATIC columns not allowed with COMPACT STORAGE\");","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (com.datastax.driver.core.exceptions.InvalidQueryException e) { if (e.getMessage().contains(\"Static columns are not supported in COMPACT STORAGE\")) { /* drop STATIC */ } else throw e; }","preventionTips":["Never combine STATIC columns and COMPACT STORAGE.","Strip STATIC markers when converting schemas to compact form.","Review DDL diffs when adding COMPACT STORAGE to existing definitions."],"tags":["cql","schema","compact-storage","static-columns"],"backgroundTag":"schema-validation-failed","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"}