{"record":{"id":"565c459d9134904b","repo":"apache/cassandra","slug":"cannot-create-s-index-on-s-non-collection-col","errorCode":null,"errorMessage":"Cannot create %s() index on %s. Non-collection columns only support simple indexes","messagePattern":"Cannot create (.+?)\\(\\) index on (.+?)\\. Non-collection columns only support simple indexes","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java","lineNumber":295,"sourceCode":"        }\n\n        if (table.isCompactTable())\n        {\n            TableMetadata.CompactTableMetadata compactTable = (TableMetadata.CompactTableMetadata) table;\n            if (column.isPrimaryKeyColumn())\n                throw new InvalidRequestException(PRIMARY_KEY_IN_COMPACT_STORAGE);\n            if (compactTable.compactValueColumn.equals(column))\n                throw new InvalidRequestException(COMPACT_COLUMN_IN_COMPACT_STORAGE);\n        }\n\n        if (column.isPartitionKey() && table.partitionKeyColumns().size() == 1)\n            throw ire(ONLY_PARTITION_KEY, column);\n\n        if (target.type == Type.FULL && isNonSAIIndex && (!baseType.isCollection() || column.type.isMultiCell()))\n            throw ire(FULL_ON_FROZEN_COLLECTIONS);\n\n        if (!baseType.isCollection() && target.type != Type.SIMPLE)\n            throw ire(NON_COLLECTION_SIMPLE_INDEX, target.type, column);\n\n        // Frozen collections are only supported with SAI indexes.\n        if (isNonSAIIndex && baseType.isCollection() && !column.type.isMultiCell())\n        {\n            if (target.type == Type.VALUES || target.type == Type.KEYS || target.type == Type.KEYS_AND_VALUES)\n            {\n                throw ire(CREATE_ON_FROZEN_COLUMN, target.type.toString(), column.name, column.name);\n            }\n        }\n\n        if (!(baseType instanceof MapType) && (target.type == Type.KEYS || target.type == Type.KEYS_AND_VALUES ))\n            throw ire(CREATE_WITH_NON_MAP_TYPE, target.type, column);\n\n        // Can't query map[key]=value on clustering key columns, so ENTRIES index would be not queryable.\n        if (column.isClusteringColumn() && baseType instanceof MapType && !column.type.isMultiCell()\n            && target.type == Type.KEYS_AND_VALUES)\n            throw ire(ENTRIES_INDEX_ON_FROZEN_MAP_CLUSTERING_KEY_NOT_SUPPORTED, column.name);\n","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java#L277-L313","documentation":"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.","triggerScenarios":"`CREATE INDEX ON t (keys(scalar_col))`, `values(int_col)`, `full(udt_col)` or `entries(map_like_scalar)` on any non-collection column.","commonSituations":"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.","solutions":["Drop the modifier: CREATE INDEX ON t (col) creates a SIMPLE index.","If the column was intended to be a map, fix the schema or the target column name.","Use KEYS/VALUES/ENTRIES only on actual map columns and FULL only on frozen collections."],"exampleFix":"// before\nCREATE INDEX ON users (keys(prefs)); // prefs is text\n// after\nCREATE INDEX ON users (prefs);","handlingStrategy":"validation","validationCode":"if (!baseType.isCollection() && target.type !== 'SIMPLE') throw new Error('non-collection columns only support SIMPLE indexes');","typeGuard":"const modifierAllowed = (baseType, targetType) => baseType.isCollection() || targetType === 'SIMPLE';","tryCatchPattern":"try { session.execute(ddl); } catch (e) { if (/only support simple indexes/.test(e.message)) { /* remove the modifier */ } else throw e; }","preventionTips":["Apply keys()/values()/full() only to collection targets","Validate column types in index-generation scripts before emitting DDL"],"tags":["cassandra","cql","secondary-index","collections"],"backgroundTag":"invalid-argument-value","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"}