{"record":{"id":"3e631af99b4a9581","repo":"prestodb/presto","slug":"cannot-drop-function-in-hive-function-namespace","errorCode":null,"errorMessage":"Cannot drop function in hive function namespace: %s","messagePattern":"Cannot drop 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":130,"sourceCode":"    }\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\n    public FunctionHandle getFunctionHandle(Optional<? extends FunctionNamespaceTransactionHandle> transactionHandle, Signature signature)\n    {\n        throw new IllegalStateException(\"Get function handle is not supported\");\n    }\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-function-namespace/src/main/java/com/facebook/presto/hive/functions/HiveFunctionNamespaceManager.java#L112-L148","documentation":"dropFunction in HiveFunctionNamespaceManager throws IllegalStateException unconditionally: the read-only hive function namespace never contains user-created SQL functions, so DROP FUNCTION against it is always rejected. This protects the built-in Hive function registry.","triggerScenarios":"DROP FUNCTION <name> where the function name resolves to the hive function namespace manager.","commonSituations":"Cleanup scripts dropping functions that were mistakenly created in a read-only namespace; attempting to 'remove' a built-in Hive function that shadows a user function.","solutions":["Drop the function from the writable namespace where it was actually created (fully qualify with that catalog/schema).","Built-in hive functions cannot be dropped — if a built-in shadows your UDF, rename your function or adjust search path ordering.","List available functions in the namespace (SHOW FUNCTIONS) to confirm which are user-defined vs built-in.","Configure and use a persistent function namespace manager for user-defined SQL functions."],"exampleFix":"// before\nDROP FUNCTION hive.default.my_add(integer, integer);\n// after\nDROP FUNCTION mycat.default.my_add(integer, integer);\n","handlingStrategy":"validation","validationCode":"if (functionName.getCatalogName().equalsIgnoreCase(\"hive\")) {\n    throw new UnsupportedOperationException(\n        \"cannot DROP FUNCTION in read-only hive namespace; built-in functions cannot be removed\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    manager.dropFunction(name, paramTypes, false);\n} catch (IllegalStateException e) {\n    // ignore if cleanup script; or target the correct writable namespace\n}","preventionTips":["Cleanup scripts should fully qualify DROP FUNCTION with the owning catalog.","Remember built-in hive functions can't be dropped — rename user functions instead of shadow-fighting.","Audit namespaces with SHOW FUNCTIONS before bulk drops."],"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"}