prestodb/presto · error · PrestoException
NOT_FOUND
NOT_FOUND
Error message
Function namespace not found: %s
What it means
createFunction validates that the function's parent namespace (catalog.schema) exists in the MySQL-backed manager before inserting. If functionNamespaceDao.functionNamespaceExists returns false, it throws NOT_FOUND because functions cannot be created in an unregistered namespace.
Source
Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/mysql/MySqlFunctionNamespaceManager.java:160
protected ScalarFunctionImplementation fetchFunctionImplementationDirect(SqlFunctionHandle functionHandle)
{
checkCatalog(functionHandle);
Optional<SqlInvokedFunction> function = functionNamespaceDao.getFunction(hash(functionHandle.getFunctionId()), functionHandle.getFunctionId(), getLongVersion(functionHandle));
return sqlInvokedFunctionToImplementation(function.orElseThrow(() -> new InvalidFunctionHandleException(functionHandle)));
}
@Override
public void createFunction(SqlInvokedFunction function, boolean replace)
{
checkCatalog(function);
checkFunctionLanguageSupported(function);
checkArgument(!function.hasVersion(), "function '%s' is already versioned", function);
QualifiedObjectName functionName = function.getFunctionId().getFunctionName();
checkFieldLength("Catalog name", functionName.getCatalogName(), MAX_CATALOG_NAME_LENGTH);
checkFieldLength("Schema name", functionName.getSchemaName(), MAX_SCHEMA_NAME_LENGTH);
if (!functionNamespaceDao.functionNamespaceExists(functionName.getCatalogName(), functionName.getSchemaName())) {
throw new PrestoException(NOT_FOUND, format("Function namespace not found: %s", functionName.getCatalogSchemaName()));
}
checkFieldLength("Function name", functionName.getObjectName(), MAX_FUNCTION_NAME_LENGTH);
if (function.getParameters().size() > MAX_PARAMETER_COUNT) {
throw new PrestoException(GENERIC_USER_ERROR, format("Function has more than %s parameters: %s", MAX_PARAMETER_COUNT, function.getParameters().size()));
}
for (Parameter parameter : function.getParameters()) {
checkFieldLength("Parameter name", parameter.getName(), MAX_PARAMETER_NAME_LENGTH);
}
checkFieldLength(
"Parameter type list",
function.getFunctionId().getArgumentTypes().stream()
.map(TypeSignature::toString)
.collect(joining(",")),
MAX_PARAMETER_TYPES_LENGTH);
checkFieldLength("Return type", function.getSignature().getReturnType().toString(), MAX_RETURN_TYPE_LENGTH);
View on GitHub (pinned to 55bb57d202)
Solutions
- Create/register the function namespace (catalog.schema) in the MySQL store first, then retry createFunction.
- Correct the catalog/schema names in the function definition.
- Verify namespace rows with the dao or SQL query functionNamespaceExists uses.
- Add a preflight check in deployment tooling that provisions missing namespaces.
Example fix
// before manager.createFunction(function, false); // namespace missing // after functionNamespaceDao.insertFunctionNamespace(catalog, schema); // provision first manager.createFunction(function, false);
Defensive patterns
Strategy: validation
Validate before calling
if (!functionNamespaceDao.functionNamespaceExists(catalog, schema)) {
provisionNamespace(catalog, schema); // or abort
} Try / catch
try {
manager.createFunction(function, false);
} catch (PrestoException e) {
if (isNotFound(e)) { provisionNamespace(catalog, schema); manager.createFunction(function, false); } else { throw e; }
} Prevention
- Provision catalog/schema namespaces before function deployment
- Validate function qualified names against known namespaces
- Add preflight checks to deployment tooling
When it happens
Trigger: Calling createFunction(function) whose functionId's qualified object name references a catalog/schema pair with no row in the function_namespace table.
Common situations: Typo in catalog or schema name of the function definition; namespace never created for this catalog; deploying functions to a new catalog before provisioning its namespace row.
Understand the failure class
Background: NOT_FOUND error code: why tRPC, Harbor, Nacos and other libraries return 404 "not found" errors for resources that may still exist — this error's family across 11 libraries.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/35a1ffbc35bdf6b6.
Report an issue: GitHub.