apache/cassandra · error · InvalidRequestException

Invalid deletion operation for frozen collection column %s

Error message

Invalid deletion operation for frozen collection column %s

What it means

An element-level DELETE was issued against a frozen collection column. Frozen collections cannot be partially mutated (including element deletion) because they are stored as a single cell; prepare rejects the operation.

Source

Thrown at src/java/org/apache/cassandra/cql3/Operation.java:526

        private final Term.Raw element;

        public ElementDeletion(ColumnIdentifier id, Term.Raw element)
        {
            this.id = id;
            this.element = element;
        }

        public ColumnIdentifier affectedColumn()
        {
            return id;
        }

        public Operation prepare(String keyspace, ColumnMetadata receiver, TableMetadata metadata) throws InvalidRequestException
        {
            if (!(receiver.type.isCollection()))
                throw new InvalidRequestException(String.format("Invalid deletion operation for non collection column %s", receiver.name));
            else if (!(receiver.type.isMultiCell()))
                throw new InvalidRequestException(String.format("Invalid deletion operation for frozen collection column %s", receiver.name));

            switch (((CollectionType<?>)receiver.type).kind)
            {
                case LIST:
                    Term idx = element.prepare(keyspace, Lists.indexSpecOf(receiver));
                    return new Lists.DiscarderByIndex(receiver, idx);
                case SET:
                    Term elt = element.prepare(keyspace, Sets.valueSpecOf(receiver));
                    return new Sets.ElementDiscarder(receiver, elt);
                case MAP:
                    Term key = element.prepare(keyspace, Maps.keySpecOf(receiver));
                    return new Maps.DiscarderByKey(receiver, key);
            }
            throw new AssertionError();
        }
    }

    public static class FieldDeletion implements RawDeletion

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Remove the frozen wrapper (recreate the column/table) so element deletes are supported
  2. Rewrite as a full-value update: read the frozen collection, remove the element client-side, SET the new value
  3. Use `DELETE col FROM t` only if discarding the entire value is acceptable
  4. Redesign the data model (e.g. non-frozen collection or separate rows) if partial mutation is a core requirement

Example fix

// before
m frozen<map<text,text>>; DELETE m['k'] FROM t WHERE id=1;
// after
m map<text,text>; DELETE m['k'] FROM t WHERE id=1;
Defensive patterns

Strategy: validation

Validate before calling

String type = session.execute("SELECT type FROM system_schema.columns WHERE keyspace_name=? AND table_name=? AND column_name=?", ks, table, col).one().getString("type");
if (type.contains("frozen")) throw new IllegalStateException("frozen collections do not support element deletes");

Try / catch

try { session.execute("DELETE col[k] FROM t WHERE id=?", id); } catch (InvalidQueryException e) { if (e.getMessage().contains("frozen collection")) { /* full-value rewrite */ } else throw e; }

Prevention

When it happens

Trigger: `DELETE m['k'] FROM t` where m is frozen<map<...>>; `DELETE l[0] FROM t` where l is frozen<list<...>>.

Common situations: Frozen types chosen for PK/index compatibility, then later element deletes attempted; schema conversions from non-frozen to frozen without query updates.

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/d90599a427334c95. Report an issue: GitHub.