apache/cassandra · error · InvalidRequestException

Cannot create %s() index on %s. Non-collection columns only

Error message

Cannot create %s() index on %s. Non-collection columns only support simple indexes

What it means

Non-collection columns only support the SIMPLE index type. Using KEYS, KEYS_AND_VALUES, ENTRIES, or FULL on a scalar column (int, text, uuid, tuple, UDT, etc.) is meaningless and rejected. Raised when target.type != SIMPLE and the base type is not a collection.

Source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java:295

        }

        if (table.isCompactTable())
        {
            TableMetadata.CompactTableMetadata compactTable = (TableMetadata.CompactTableMetadata) table;
            if (column.isPrimaryKeyColumn())
                throw new InvalidRequestException(PRIMARY_KEY_IN_COMPACT_STORAGE);
            if (compactTable.compactValueColumn.equals(column))
                throw new InvalidRequestException(COMPACT_COLUMN_IN_COMPACT_STORAGE);
        }

        if (column.isPartitionKey() && table.partitionKeyColumns().size() == 1)
            throw ire(ONLY_PARTITION_KEY, column);

        if (target.type == Type.FULL && isNonSAIIndex && (!baseType.isCollection() || column.type.isMultiCell()))
            throw ire(FULL_ON_FROZEN_COLLECTIONS);

        if (!baseType.isCollection() && target.type != Type.SIMPLE)
            throw ire(NON_COLLECTION_SIMPLE_INDEX, target.type, column);

        // Frozen collections are only supported with SAI indexes.
        if (isNonSAIIndex && baseType.isCollection() && !column.type.isMultiCell())
        {
            if (target.type == Type.VALUES || target.type == Type.KEYS || target.type == Type.KEYS_AND_VALUES)
            {
                throw ire(CREATE_ON_FROZEN_COLUMN, target.type.toString(), column.name, column.name);
            }
        }

        if (!(baseType instanceof MapType) && (target.type == Type.KEYS || target.type == Type.KEYS_AND_VALUES ))
            throw ire(CREATE_WITH_NON_MAP_TYPE, target.type, column);

        // Can't query map[key]=value on clustering key columns, so ENTRIES index would be not queryable.
        if (column.isClusteringColumn() && baseType instanceof MapType && !column.type.isMultiCell()
            && target.type == Type.KEYS_AND_VALUES)
            throw ire(ENTRIES_INDEX_ON_FROZEN_MAP_CLUSTERING_KEY_NOT_SUPPORTED, column.name);

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Drop the modifier: CREATE INDEX ON t (col) creates a SIMPLE index.
  2. If the column was intended to be a map, fix the schema or the target column name.
  3. Use KEYS/VALUES/ENTRIES only on actual map columns and FULL only on frozen collections.

Example fix

// before
CREATE INDEX ON users (keys(prefs)); // prefs is text
// after
CREATE INDEX ON users (prefs);
Defensive patterns

Strategy: validation

Validate before calling

if (!baseType.isCollection() && target.type !== 'SIMPLE') throw new Error('non-collection columns only support SIMPLE indexes');

Type guard

const modifierAllowed = (baseType, targetType) => baseType.isCollection() || targetType === 'SIMPLE';

Try / catch

try { session.execute(ddl); } catch (e) { if (/only support simple indexes/.test(e.message)) { /* remove the modifier */ } else throw e; }

Prevention

When it happens

Trigger: `CREATE INDEX ON t (keys(scalar_col))`, `values(int_col)`, `full(udt_col)` or `entries(map_like_scalar)` on any non-collection column.

Common situations: Copy-paste from a map index example onto a text column; template-driven index generation applying entries() everywhere; typos where the wrong column name sits inside the modifier.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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