{"record":{"id":"35a1ffbc35bdf6b6","repo":"prestodb/presto","slug":"not-found-35a1ff","errorCode":"NOT_FOUND","errorMessage":"Function namespace not found: %s","messagePattern":"Function namespace not found: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/mysql/MySqlFunctionNamespaceManager.java","lineNumber":160,"sourceCode":"    protected ScalarFunctionImplementation fetchFunctionImplementationDirect(SqlFunctionHandle functionHandle)\n    {\n        checkCatalog(functionHandle);\n        Optional<SqlInvokedFunction> function = functionNamespaceDao.getFunction(hash(functionHandle.getFunctionId()), functionHandle.getFunctionId(), getLongVersion(functionHandle));\n        return sqlInvokedFunctionToImplementation(function.orElseThrow(() -> new InvalidFunctionHandleException(functionHandle)));\n    }\n\n    @Override\n    public void createFunction(SqlInvokedFunction function, boolean replace)\n    {\n        checkCatalog(function);\n        checkFunctionLanguageSupported(function);\n        checkArgument(!function.hasVersion(), \"function '%s' is already versioned\", function);\n\n        QualifiedObjectName functionName = function.getFunctionId().getFunctionName();\n        checkFieldLength(\"Catalog name\", functionName.getCatalogName(), MAX_CATALOG_NAME_LENGTH);\n        checkFieldLength(\"Schema name\", functionName.getSchemaName(), MAX_SCHEMA_NAME_LENGTH);\n        if (!functionNamespaceDao.functionNamespaceExists(functionName.getCatalogName(), functionName.getSchemaName())) {\n            throw new PrestoException(NOT_FOUND, format(\"Function namespace not found: %s\", functionName.getCatalogSchemaName()));\n        }\n        checkFieldLength(\"Function name\", functionName.getObjectName(), MAX_FUNCTION_NAME_LENGTH);\n\n        if (function.getParameters().size() > MAX_PARAMETER_COUNT) {\n            throw new PrestoException(GENERIC_USER_ERROR, format(\"Function has more than %s parameters: %s\", MAX_PARAMETER_COUNT, function.getParameters().size()));\n        }\n        for (Parameter parameter : function.getParameters()) {\n            checkFieldLength(\"Parameter name\", parameter.getName(), MAX_PARAMETER_NAME_LENGTH);\n        }\n\n        checkFieldLength(\n                \"Parameter type list\",\n                function.getFunctionId().getArgumentTypes().stream()\n                        .map(TypeSignature::toString)\n                        .collect(joining(\",\")),\n                MAX_PARAMETER_TYPES_LENGTH);\n        checkFieldLength(\"Return type\", function.getSignature().getReturnType().toString(), MAX_RETURN_TYPE_LENGTH);\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/mysql/MySqlFunctionNamespaceManager.java#L142-L178","documentation":"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.","triggerScenarios":"Calling createFunction(function) whose functionId's qualified object name references a catalog/schema pair with no row in the function_namespace table.","commonSituations":"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.","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."],"exampleFix":"// before\nmanager.createFunction(function, false); // namespace missing\n// after\nfunctionNamespaceDao.insertFunctionNamespace(catalog, schema); // provision first\nmanager.createFunction(function, false);","handlingStrategy":"validation","validationCode":"if (!functionNamespaceDao.functionNamespaceExists(catalog, schema)) {\n    provisionNamespace(catalog, schema); // or abort\n}","typeGuard":null,"tryCatchPattern":"try {\n    manager.createFunction(function, false);\n} catch (PrestoException e) {\n    if (isNotFound(e)) { provisionNamespace(catalog, schema); manager.createFunction(function, false); } else { throw e; }\n}","preventionTips":["Provision catalog/schema namespaces before function deployment","Validate function qualified names against known namespaces","Add preflight checks to deployment tooling"],"tags":["sql-functions","mysql","not-found"],"backgroundTag":"parent-issue-not-found","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"}