{"record":{"id":"8aa3fe5193a1f9c5","repo":"prestodb/presto","slug":"cannot-create-function-in-hive-function-namespace","errorCode":null,"errorMessage":"Cannot create function in hive function namespace: %s","messagePattern":"Cannot create 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":120,"sourceCode":"    /**\n     * this function namespace manager does not support transaction.\n     */\n    public FunctionNamespaceTransactionHandle beginTransaction()\n    {\n        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","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java#L102-L138","documentation":"HiveFunctionNamespaceManager backs the 'hive' function namespace, which is read-only: it only surfaces built-in Hive functions. createFunction unconditionally throws IllegalStateException for any function name, since SQL-invoked function creation is not supported in this namespace.","triggerScenarios":"CREATE FUNCTION executed with a function name whose catalog/schema resolves to the hive function namespace, e.g. CREATE FUNCTION hive.default.my_fn(...) ...","commonSituations":"Users following SQL UDF tutorials without realizing built-in namespaces are read-only; creating functions in a catalog mapped to the hive function namespace instead of a persistent namespace (e.g., a JDBC-backed one).","solutions":["Create the function in a writable function namespace (configure a persistent function namespace manager, e.g. JDBC/MySQL-backed) instead of 'hive'.","Qualify the function with a catalog/schema bound to that writable namespace: CREATE FUNCTION mycat.default.my_fn(...).","If the logic is needed globally, implement it as a Presto plugin (custom function) rather than a SQL-invoked function.","Verify function-namespace-manager configuration in etc/function-namespace.properties to see which namespaces are read-only."],"exampleFix":"// before\nCREATE FUNCTION hive.default.my_add(a integer, b integer) ...\n// after\nCREATE FUNCTION mycat.default.my_add(a integer, b integer) RETURNS integer ...\n","handlingStrategy":"validation","validationCode":"if (functionName.getCatalogName().equalsIgnoreCase(\"hive\")) {\n    throw new UnsupportedOperationException(\n        \"cannot CREATE FUNCTION in read-only hive namespace; use a persistent namespace catalog\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    functionNamespaceManager.createFunction(fn, false);\n} catch (IllegalStateException e) {\n    // redirect creation to a writable namespace manager\n}","preventionTips":["Configure a persistent (e.g., JDBC-backed) function namespace for user SQL functions.","Qualify CREATE FUNCTION with the writable catalog, not 'hive'.","Document in team runbooks that built-in namespaces are read-only."],"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"}