{"record":{"id":"77e40ded891f93f4","repo":"prestodb/presto","slug":"not-supported-77e40d","errorCode":"NOT_SUPPORTED","errorMessage":"Alter Function is not supported in InMemoryFunctionNamespaceManager","messagePattern":"Alter Function is not supported in InMemoryFunctionNamespaceManager","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-function-namespace-managers-common/src/main/java/com/facebook/presto/functionNamespace/testing/InMemoryFunctionNamespaceManager.java","lineNumber":86,"sourceCode":"    {\n        checkFunctionLanguageSupported(function);\n        SqlFunctionId functionId = function.getFunctionId();\n        if (!replace && latestFunctions.containsKey(function.getFunctionId())) {\n            throw new PrestoException(GENERIC_USER_ERROR, format(\"Function '%s' already exists\", functionId.getId()));\n        }\n\n        SqlInvokedFunction replacedFunction = latestFunctions.get(functionId);\n        long version = 1;\n        if (replacedFunction != null) {\n            version = parseLong(replacedFunction.getRequiredVersion()) + 1;\n        }\n        latestFunctions.put(functionId, function.withVersion(String.valueOf(version)));\n    }\n\n    @Override\n    public void alterFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, AlterRoutineCharacteristics alterRoutineCharacteristics)\n    {\n        throw new PrestoException(NOT_SUPPORTED, \"Alter Function is not supported in InMemoryFunctionNamespaceManager\");\n    }\n\n    @Override\n    public synchronized void dropFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, boolean exists)\n    {\n        throw new PrestoException(NOT_SUPPORTED, \"Drop Function is not supported in InMemoryFunctionNamespaceManager\");\n    }\n\n    /**\n     * likePattern / escape is not used for optimization, returning all functions.\n     */\n    @Override\n    public Collection<SqlInvokedFunction> listFunctions(Optional<String> likePattern, Optional<String> escape)\n    {\n        return latestFunctions.values();\n    }\n\n    @Override","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-function-namespace-managers-common/src/main/java/com/facebook/presto/functionNamespace/testing/InMemoryFunctionNamespaceManager.java#L68-L104","documentation":"The InMemoryFunctionNamespaceManager explicitly does not implement alterFunction and always throws NOT_SUPPORTED. The testing-only in-memory manager supports create/list/get only, so any ALTER FUNCTION routed to it is rejected.","triggerScenarios":"Calling alterFunction (or running ALTER FUNCTION statements) against a catalog backed by the in-memory function namespace manager, regardless of arguments.","commonSituations":"Running integration tests that exercise ALTER FUNCTION paths; pointing a dev catalog at the in-memory manager and executing production SQL containing ALTER FUNCTION.","solutions":["Avoid ALTER FUNCTION on in-memory-backed catalogs; recreate the function with CREATE OR REPLACE instead.","Use a persistent function namespace manager (e.g. JDBC-backed) if alter semantics are required.","Skip/condition test cases that alter functions when using this manager."],"exampleFix":"// before\nALTER FUNCTION test_ns.fn(x BIGINT) SET LANGUAGE SQL;\n// after\nCREATE OR REPLACE FUNCTION test_ns.fn(x BIGINT) RETURNS BIGINT LANGUAGE SQL RETURN ...;","handlingStrategy":"validation","validationCode":"if (manager instanceof InMemoryFunctionNamespaceManager) {\n    throw new UnsupportedOperationException(\"ALTER FUNCTION not supported on in-memory manager; use CREATE OR REPLACE\");\n}","typeGuard":"boolean supportsAlter(FunctionNamespaceManager m) {\n    return !(m instanceof InMemoryFunctionNamespaceManager);\n}","tryCatchPattern":"try {\n    manager.alterFunction(name, paramTypes, characteristics);\n} catch (PrestoException e) {\n    if (e.getErrorCode().equals(NOT_SUPPORTED.toErrorCode())) {\n        // recreate the function instead of altering\n    }\n}","preventionTips":["Do not run ALTER FUNCTION against catalogs backed by the in-memory test manager.","Prefer CREATE OR REPLACE for mutating function definitions in tests.","Use a persistent namespace manager when testing alter semantics.","Document manager capabilities in test fixtures."],"tags":["not-supported","alter-function","in-memory","testing"],"backgroundTag":"operation-not-supported","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}