{"record":{"id":"a64f4efceb15018f","repo":"apache/cassandra","slug":"map-entry-predicates-on-frozen-map-column-s-are-n-a64f4e","errorCode":null,"errorMessage":"Map-entry predicates on frozen map column %s are not supported","messagePattern":"Map-entry predicates on frozen map column (.+?) are not supported","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/restrictions/MergedRestriction.java","lineNumber":137,"sourceCode":"    public boolean isMultiColumn()\n    {\n        return isMultiColumn;\n    }\n\n    private static void validate(SimpleRestriction restriction, SimpleRestriction other)\n    {\n        checkOperator(restriction);\n        checkOperator(other);\n\n        if (restriction.isContains() != other.isContains())\n        {\n            SimpleRestriction mapEntryRestriction = restriction.isContains() ? restriction : other;\n            if (mapEntryRestriction.isMapElementExpression())\n            {\n                ColumnMetadata column = mapEntryRestriction.firstColumn();\n                if (column.type.isFrozenCollection())\n                {\n                    throw invalidRequest(Relation.FROZEN_MAP_ENTRY_PREDICATES_NOT_SUPPORTED, column.name);\n                }\n            }\n\n            throw invalidRequest(\"Collection column %s can only be restricted by CONTAINS, CONTAINS KEY, NOT_CONTAINS, NOT_CONTAINS_KEY\" +\n                                 \" or map-entry equality if it already restricted by one of those\",\n                                 restriction.firstColumn().name);\n        }\n\n        if (restriction.isSlice() && other.isSlice())\n        {\n            ColumnMetadata firstColumn = restriction.firstColumn();\n            ColumnMetadata otherFirstColumn = other.firstColumn();\n            if (!firstColumn.equals(otherFirstColumn))\n            {\n                ColumnMetadata column = firstColumn.position() > otherFirstColumn.position() ? firstColumn\n                                                                                             : otherFirstColumn;\n\n                throw invalidRequest(\"Column \\\"%s\\\" cannot be restricted by two inequalities not starting with the same column\",","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/restrictions/MergedRestriction.java#L119-L155","documentation":"Map-entry predicates (map[col] = value style restrictions) are only supported on non-frozen maps. When a CONTAINS/CONTAINS KEY restriction is merged with a map-element expression on a frozen collection column, MergedRestriction.validate throws this error because frozen collections are stored as a single blob and cannot be indexed per-entry.","triggerScenarios":"A query like frozen_map_col CONTAINS KEY 'k' or merging a CONTAINS restriction with a map-entry equality (frozen_map_col['k'] = v) on a column declared FROZEN<map<...>>; validate() in MergedRestriction detects isMapElementExpression() on a frozenCollection type.","commonSituations":"Schema was altered to frozen (or created as frozen) while queries assume thawed per-entry lookup semantics; migrating from thawed to frozen collections for compaction reasons breaks existing queries.","solutions":["Drop the map-entry/CONTAINS restriction on the frozen column and query on the full frozen value with EQ instead","Redefine the column as a non-frozen map if per-entry predicates are required (requires table migration)","Create a separate lookup/denormalized table keyed by the map key"],"exampleFix":"// before\nCREATE TABLE t (id int PRIMARY KEY, tags frozen<map<text,text>>);\nSELECT * FROM t WHERE tags['env'] = 'prod';\n// after\nCREATE TABLE t (id int PRIMARY KEY, tags map<text,text>);\nSELECT * FROM t WHERE tags['env'] = 'prod';","handlingStrategy":"type-guard","validationCode":"// guard before issuing a map-entry predicate\nColumnMetadata col = schema.getColumn(\"tags\");\nif (col.type.isFrozenCollection())\n    throw new IllegalArgumentException(\"map-entry predicates unsupported on frozen column \" + col.name);","typeGuard":"boolean supportsMapEntryPredicate(ColumnMetadata col) { return col.type instanceof MapType && !col.type.isFrozenCollection(); }","tryCatchPattern":null,"preventionTips":["Prefer non-frozen collections when per-entry queries are planned","Keep schema definitions and query templates in sync in code review","Add integration tests that prepare every query template against the real schema"],"tags":["cql","frozen-collection","map-entry"],"backgroundTag":"unsupported-operation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}