prestodb/presto · error · PrestoException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
Alter Function is not supported in InMemoryFunctionNamespaceManager
What it means
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.
Source
Thrown at presto-function-namespace-managers-common/src/main/java/com/facebook/presto/functionNamespace/testing/InMemoryFunctionNamespaceManager.java:86
{
checkFunctionLanguageSupported(function);
SqlFunctionId functionId = function.getFunctionId();
if (!replace && latestFunctions.containsKey(function.getFunctionId())) {
throw new PrestoException(GENERIC_USER_ERROR, format("Function '%s' already exists", functionId.getId()));
}
SqlInvokedFunction replacedFunction = latestFunctions.get(functionId);
long version = 1;
if (replacedFunction != null) {
version = parseLong(replacedFunction.getRequiredVersion()) + 1;
}
latestFunctions.put(functionId, function.withVersion(String.valueOf(version)));
}
@Override
public void alterFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, AlterRoutineCharacteristics alterRoutineCharacteristics)
{
throw new PrestoException(NOT_SUPPORTED, "Alter Function is not supported in InMemoryFunctionNamespaceManager");
}
@Override
public synchronized void dropFunction(QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes, boolean exists)
{
throw new PrestoException(NOT_SUPPORTED, "Drop Function is not supported in InMemoryFunctionNamespaceManager");
}
/**
* likePattern / escape is not used for optimization, returning all functions.
*/
@Override
public Collection<SqlInvokedFunction> listFunctions(Optional<String> likePattern, Optional<String> escape)
{
return latestFunctions.values();
}
@OverrideView on GitHub (pinned to 55bb57d202)
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.
Example fix
// before ALTER FUNCTION test_ns.fn(x BIGINT) SET LANGUAGE SQL; // after CREATE OR REPLACE FUNCTION test_ns.fn(x BIGINT) RETURNS BIGINT LANGUAGE SQL RETURN ...;
Defensive patterns
Strategy: validation
Validate before calling
if (manager instanceof InMemoryFunctionNamespaceManager) {
throw new UnsupportedOperationException("ALTER FUNCTION not supported on in-memory manager; use CREATE OR REPLACE");
} Type guard
boolean supportsAlter(FunctionNamespaceManager m) {
return !(m instanceof InMemoryFunctionNamespaceManager);
} Try / catch
try {
manager.alterFunction(name, paramTypes, characteristics);
} catch (PrestoException e) {
if (e.getErrorCode().equals(NOT_SUPPORTED.toErrorCode())) {
// recreate the function instead of altering
}
} Prevention
- 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.
When it happens
Trigger: Calling alterFunction (or running ALTER FUNCTION statements) against a catalog backed by the in-memory function namespace manager, regardless of arguments.
Common situations: Running integration tests that exercise ALTER FUNCTION paths; pointing a dev catalog at the in-memory manager and executing production SQL containing ALTER FUNCTION.
Understand the failure class
Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/77e40ded891f93f4.
Report an issue: GitHub.