apache/cassandra · error · InvalidRequestException

Non-frozen collections and UDTs are not supported with COMPA

Error message

Non-frozen collections and UDTs are not supported with COMPACT STORAGE

What it means

COMPACT STORAGE tables emulate legacy Thrift layouts, which cannot represent non-frozen (multi-cell) collections or user-defined types. The compact-table validator rejects any column whose type is multi-cell, throwing this error at CREATE TABLE time.

Source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java:436

        {
            columns.forEach((column, properties) -> {
                if (staticColumns.contains(column))
                    builder.addStaticColumn(column, properties.type, properties.mask, columnConstraints.get(column));
                else
                    builder.addRegularColumn(column, properties.type, properties.mask, columnConstraints.get(column));
            });
        }

        return builder;
    }

    private void validateCompactTable(List<ColumnProperties> clusteringColumnProperties,
                                      Map<ColumnIdentifier, ColumnProperties> columns)
    {
        boolean isDense = !clusteringColumnProperties.isEmpty();

        if (columns.values().stream().anyMatch(c -> c.type.isMultiCell()))
            throw ire("Non-frozen collections and UDTs are not supported with COMPACT STORAGE");
        if (!staticColumns.isEmpty())
            throw ire("Static columns are not supported in COMPACT STORAGE tables");

        if (clusteringColumnProperties.isEmpty())
        {
            // It's a thrift "static CF" so there should be some columns definition
            if (columns.isEmpty())
                throw ire("No definition found that is not part of the PRIMARY KEY");
        }

        if (isDense)
        {
            // We can have no columns (only the PK), but we can't have more than one.
            if (columns.size() > 1)
                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(), ", ")));
        }
        else
        {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Freeze the collection/UDT: use frozen<set<int>>, frozen<map<...>>, or frozen<my_udt>.
  2. Drop the COMPACT STORAGE option and use a standard table.
  3. Remove the collection column from the compact table.

Example fix

// before
CREATE TABLE t (pk int PRIMARY KEY, tags set<int>) WITH COMPACT STORAGE;
// after
CREATE TABLE t (pk int PRIMARY KEY, tags frozen<set<int>>) WITH COMPACT STORAGE;
Defensive patterns

Strategy: validation

Validate before calling

// With COMPACT STORAGE, collections/UDTs must be frozen:
boolean compactStorage = true;
List<String> colTypes = List.of("set<int>"); // non-frozen multi-cell types rejected
if (compactStorage && colTypes.stream().anyMatch(t -> t.matches("(set|list|map)<.*>") && !t.startsWith("frozen<"))) throw new IllegalArgumentException("freeze collections/UDTs or drop COMPACT STORAGE");

Try / catch

try { session.execute(ddl); } catch (com.datastax.driver.core.exceptions.InvalidQueryException e) { if (e.getMessage().contains("Non-frozen collections")) { /* freeze type or drop COMPACT STORAGE */ } else throw e; }

Prevention

When it happens

Trigger: CREATE TABLE ... WITH COMPACT STORAGE where any column is a non-frozen list, set, map, or UDT.

Common situations: Porting a modern schema to COMPACT STORAGE for thrift compatibility; adding a collection column to an existing COMPACT STORAGE table via ALTER.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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