prestodb/presto · error · PrestoException
GENERIC_USER_ERROR
GENERIC_USER_ERROR
Error message
Function '%s' is missing from cache
What it means
JsonFileBasedFunctionNamespaceManager resolves SQL-invoked aggregate function implementations from an in-memory cache keyed by SqlFunctionHandle. If the handle is absent from aggregationImplementationByHandle and the function id is not in latestFunctions, it throws GENERIC_USER_ERROR because the function metadata was never loaded (or was evicted/changed) from the JSON file.
Source
Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/json/JsonFileBasedFunctionNamespaceManager.java:100
super(catalogName, sqlFunctionExecutors, config);
this.managerConfig = requireNonNull(managerConfig, "managerConfig is null");
this.functionDefinitionProvider = requireNonNull(functionDefinitionProvider, "functionDefinitionProvider is null");
bootstrapNamespaceFromFile();
}
@Override
public final AggregationFunctionImplementation getAggregateFunctionImplementation(FunctionHandle functionHandle, TypeManager typeManager)
{
checkCatalog(functionHandle);
checkArgument(functionHandle instanceof SqlFunctionHandle, "Unsupported FunctionHandle type '%s'", functionHandle.getClass().getSimpleName());
SqlFunctionHandle sqlFunctionHandle = (SqlFunctionHandle) functionHandle;
// Cache results if applicable
if (!aggregationImplementationByHandle.containsKey(sqlFunctionHandle)) {
SqlFunctionId functionId = sqlFunctionHandle.getFunctionId();
if (!latestFunctions.containsKey(functionId)) {
throw new PrestoException(GENERIC_USER_ERROR, format("Function '%s' is missing from cache", functionId.getId()));
}
aggregationImplementationByHandle.put(
sqlFunctionHandle,
sqlInvokedFunctionToAggregationImplementation(latestFunctions.get(functionId), typeManager));
}
return aggregationImplementationByHandle.get(sqlFunctionHandle);
}
private static SqlInvokedFunction copyFunction(SqlInvokedFunction function)
{
return new SqlInvokedFunction(
function.getSignature().getName(),
function.getParameters(),
function.getSignature().getTypeVariableConstraints(),
function.getSignature().getLongVariableConstraints(),
function.getSignature().getReturnType(),View on GitHub (pinned to 55bb57d202)
Solutions
- Refresh/reload the function namespace so latestFunctions contains the function id, then re-run the query.
- Re-create the missing SQL-invoked function (e.g. via a coordinator that supports createFunction against this manager).
- Regenerate the query so it produces fresh SqlFunctionHandles matching the current function registry.
- Check that the JSON file path config points at the file actually containing the function definitions.
Defensive patterns
Strategy: try-catch
Validate before calling
// check the manager still knows the function before planning against it
boolean known = manager.listFunctions(Optional.empty(), Optional.empty()).stream()
.anyMatch(f -> f.getFunctionId().getId().equals(expectedId)); Try / catch
try {
impl = manager.getAggregateFunctionImplementation(handle);
} catch (PrestoException e) {
if (e.getErrorCode().getCode() == GENERIC_USER_ERROR.toErrorCode().getCode()) {
manager.loadInternalFunctions(); // refresh cache, then retry
} else { throw e; }
} Prevention
- Reload the namespace after editing the JSON function file
- Avoid holding function handles across namespace reloads
- Ensure the JSON path config matches the actual function definitions file
When it happens
Trigger: Calling getAggregateFunctionImplementation with a SqlFunctionHandle whose functionId is no longer (or never was) in latestFunctions — e.g. the JSON function file was reloaded/replaced after the handle was created, or the function was dropped.
Common situations: Cluster caches stale function handles after the JSON namespace file is edited out-of-band; a query plan references a function version that no longer exists; node started before the function file populated latestFunctions.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/e85814c3a2aedf5f.
Report an issue: GitHub.