{"record":{"id":"d40386a5fcc8d401","repo":"prestodb/presto","slug":"cannot-alter-function-in-hive-function-namespace","errorCode":null,"errorMessage":"Cannot alter function in hive function namespace: %s","messagePattern":"Cannot alter function in hive function namespace: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java","lineNumber":125,"sourceCode":"        return new EmptyTransactionHandle();\n    }\n\n    public void commit(FunctionNamespaceTransactionHandle transactionHandle)\n    {\n    }\n\n    public void abort(FunctionNamespaceTransactionHandle transactionHandle)\n    {\n    }\n\n    public void createFunction(SqlInvokedFunction function, boolean replace)\n    {\n        throw new IllegalStateException(format(\"Cannot create function in hive function namespace: %s\", function.getSignature().getName()));\n    }\n\n    public void alterFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, AlterRoutineCharacteristics alterRoutineCharacteristics)\n    {\n        throw new IllegalStateException(format(\"Cannot alter function in hive function namespace: %s\", functionName));\n    }\n\n    public void dropFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, boolean exists)\n    {\n        throw new IllegalStateException(format(\"Cannot drop function in hive function namespace: %s\", functionName));\n    }\n\n    @Override\n    public Collection<HiveFunction> listFunctions(Optional<String> likePattern, Optional<String> escape)\n    {\n        return getCurrentFunctionNames().stream().map(functionName -> createDummyHiveFunction(functionName)).collect(toImmutableList());\n    }\n\n    public Collection<HiveFunction> getFunctions(Optional<? extends FunctionNamespaceTransactionHandle> transactionHandle, QualifiedObjectName functionName)\n    {\n        throw new IllegalStateException(\"Get function is not supported\");\n    }\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java#L107-L143","documentation":"alterFunction in HiveFunctionNamespaceManager throws IllegalStateException for every call: the hive function namespace is read-only and supports neither CREATE, ALTER, nor DROP of SQL-invoked functions. The error names the function so the caller knows which definition was targeted.","triggerScenarios":"ALTER FUNCTION <name> (or alterFunction via the FunctionAndTypeManager) where the function's namespace resolves to the hive namespace manager.","commonSituations":"Trying to change a characteristic (SECURITY, COMMENT, signature) of a function registered in the built-in hive namespace; scripts that assumed all namespaces are mutable.","solutions":["Alter the function in a writable (persistent) function namespace; the built-in hive namespace cannot store user functions.","Fully qualify the function with a catalog mapped to the persistent namespace manager.","If the function truly lives in hive namespace, it is built-in — you cannot modify it; define your own under a different name/namespace.","Check the function-namespace configuration to confirm which manager owns the target catalog."],"exampleFix":"// before\nALTER FUNCTION hive.default.my_add(a integer, b integer) ...\n// after\nALTER FUNCTION mycat.default.my_add(a integer, b integer) ...\n","handlingStrategy":"validation","validationCode":"if (functionName.getCatalogName().equalsIgnoreCase(\"hive\")) {\n    throw new UnsupportedOperationException(\n        \"cannot ALTER FUNCTION in read-only hive namespace; use a persistent namespace catalog\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    manager.alterFunction(name, paramTypes, characteristics);\n} catch (IllegalStateException e) {\n    // recreate the function in a writable namespace instead\n}","preventionTips":["Create user functions only in writable namespaces so ALTER/DROP work later.","Built-in hive functions are immutable — never script ALTERs against them.","Verify namespace ownership via SHOW FUNCTIONS / catalog config before altering."],"tags":["functions","sql-udf","hive","not-supported"],"backgroundTag":"readonly-function-namespace","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}