{"record":{"id":"988fed84f1122307","repo":"apache/cassandra","slug":"return-type-s-cannot-be-frozen-remove-frozen","errorCode":null,"errorMessage":"Return type '%s' cannot be frozen; remove frozen<> modifier from '%s'","messagePattern":"Return type '(.+?)' cannot be frozen; remove frozen<> modifier from '(.+?)'","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateFunctionStatement.java","lineNumber":114,"sourceCode":"    {\n        if (ifNotExists && orReplace)\n            throw ire(\"Cannot use both 'OR REPLACE' and 'IF NOT EXISTS' directives\");\n\n        UDFunction.assertUdfsEnabled(language);\n\n        if (!FunctionName.isNameValid(functionName))\n            throw ire(\"Function name '%s' is invalid\", functionName);\n\n        if (new HashSet<>(argumentNames).size() != argumentNames.size())\n            throw ire(\"Duplicate argument names for given function %s with argument names %s\", functionName, argumentNames);\n\n        rawArgumentTypes.stream()\n                        .filter(raw -> !raw.isImplicitlyFrozen() && raw.isFrozen())\n                        .findFirst()\n                        .ifPresent(t -> { throw ire(\"Argument '%s' cannot be frozen; remove frozen<> modifier from '%s'\", t, t); });\n\n        if (!rawReturnType.isImplicitlyFrozen() && rawReturnType.isFrozen())\n            throw ire(\"Return type '%s' cannot be frozen; remove frozen<> modifier from '%s'\", rawReturnType, rawReturnType);\n\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n        if (null == keyspace)\n            throw ire(\"Keyspace '%s' doesn't exist\", keyspaceName);\n\n        List<AbstractType<?>> argumentTypes =\n            rawArgumentTypes.stream()\n                            .map(t -> t.prepare(keyspaceName, keyspace.types).getType().udfType())\n                            .collect(toList());\n        AbstractType<?> returnType = rawReturnType.prepare(keyspaceName, keyspace.types).getType().udfType();\n\n        UDFunction function =\n            UDFunction.create(new FunctionName(keyspaceName, functionName),\n                              argumentNames,\n                              argumentTypes,\n                              returnType,\n                              calledOnNullInput,","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateFunctionStatement.java#L96-L132","documentation":"A CREATE FUNCTION statement declared a frozen< > return type, which Cassandra rejects. Function return types must be non-frozen; the statement validates the raw return type is not explicitly frozen before preparing it.","triggerScenarios":"CREATE FUNCTION whose RETURNS clause uses frozen<...>, e.g. RETURNS frozen<list<int>>.","commonSituations":"Copy-pasting a frozen column type into the RETURNS clause; authoring UDFs that mirror table schema types verbatim.","solutions":["Remove frozen<> from the RETURNS clause","Declare the return type without the frozen modifier, e.g. RETURNS list<int>","Keep frozen<> only where table schemas require it"],"exampleFix":"// before\nCREATE FUNCTION ks.f() RETURNS frozen<list<int>> ...\n// after\nCREATE FUNCTION ks.f() RETURNS list<int> ...","handlingStrategy":"validation","validationCode":"if (!rawReturnType.isImplicitlyFrozen() && rawReturnType.isFrozen()) throw new IllegalArgumentException(\"Remove frozen<> from return type\");","typeGuard":"boolean isFrozenReturn(CQLType raw) { return !raw.isImplicitlyFrozen() && raw.isFrozen(); }","tryCatchPattern":"try { session.execute(stmt); } catch (InvalidRequestException e) { if (e.getMessage().startsWith(\"Return type\") && e.getMessage().contains(\"frozen\")) { /* fix RETURNS clause */ } else throw e; }","preventionTips":["Keep RETURNS clauses free of frozen<>","Templated DDL should only inject frozen for table columns","Test UDF DDL against a scratch keyspace before production"],"tags":["cql","udf","frozen","validation"],"backgroundTag":"schema-validation-failed","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"}