apache/cassandra · error · InvalidRequestException

Invalid deletion operation for non collection column %s

Error message

Invalid deletion operation for non collection column %s

What it means

An element/field-level DELETE (e.g. `DELETE tags['k'] FROM t` or `DELETE l[0] FROM t`) was issued against a column that is not a collection. Only collection columns support partial deletion operations, so prepare rejects it.

Source

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

    {
        private final ColumnIdentifier id;
        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();
        }
    }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Verify the column is a non-frozen collection via DESCRIBE TABLE
  2. To delete a scalar entirely use `DELETE col FROM t WHERE ...` (whole column tombstone), not element syntax
  3. Fix the column name in the statement if a typo targeted the wrong column
  4. Recreate/migrate the column as a collection if partial deletion semantics are required

Example fix

// before (col is text)
DELETE col['k'] FROM t WHERE id=1;
// after
DELETE col 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.startsWith("list") || type.startsWith("set") || type.startsWith("map"))) throw new IllegalStateException("element delete requires a collection column");

Try / catch

try { session.execute("DELETE col[key] FROM t WHERE k=?", k); } catch (InvalidQueryException e) { if (e.getMessage().contains("non collection column")) { /* delete whole column instead */ } else throw e; }

Prevention

When it happens

Trigger: `DELETE col[key] FROM t ...` where col is a scalar (text, int, etc.) or non-collection UDT usage; element index syntax applied to plain columns.

Common situations: Assuming JSON-path-like deletion on scalar columns; schema drift (column changed from map to text); typos targeting the wrong column.

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