{"record":{"id":"618f1a64b7b2d9bb","repo":"prestodb/presto","slug":"generic-user-error-618f1a","errorCode":"GENERIC_USER_ERROR","errorMessage":"Remote functions are not enabled","messagePattern":"Remote functions are not enabled","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/PlanRemoteProjections.java","lineNumber":95,"sourceCode":"    public Pattern<ProjectNode> getPattern()\n    {\n        return PATTERN;\n    }\n\n    @Override\n    public Result apply(ProjectNode node, Captures captures, Rule.Context context)\n    {\n        if (!node.getLocality().equals(UNKNOWN)) {\n            // Already planned\n            return Result.empty();\n        }\n        // Fast check for remote functions\n        if (node.getAssignments().getExpressions().stream().noneMatch(expression -> expression.accept(new ExternalCallExpressionChecker(functionAndTypeManager), null))) {\n            // No remote function\n            return Result.ofPlanNode(new ProjectNode(node.getSourceLocation(), node.getId(), node.getSource(), node.getAssignments(), LOCAL));\n        }\n        if (!isRemoteFunctionsEnabled(context.getSession())) {\n            throw new PrestoException(GENERIC_USER_ERROR, \"Remote functions are not enabled\");\n        }\n        List<ProjectionContext> projectionContexts = planRemoteAssignments(node.getAssignments(), context.getVariableAllocator());\n        checkState(!projectionContexts.isEmpty(), \"Expect non-empty projectionContexts\");\n        PlanNode rewritten = node.getSource();\n        for (ProjectionContext projectionContext : projectionContexts) {\n            rewritten = new ProjectNode(node.getSourceLocation(), context.getIdAllocator().getNextId(), rewritten, Assignments.builder().putAll(projectionContext.getProjections()).build(), projectionContext.remote ? REMOTE : LOCAL);\n        }\n        return Result.ofPlanNode(rewritten);\n    }\n\n    @VisibleForTesting\n    public List<ProjectionContext> planRemoteAssignments(Assignments assignments, VariableAllocator variableAllocator)\n    {\n        ImmutableList.Builder<List<ProjectionContext>> assignmentProjections = ImmutableList.builder();\n        for (Map.Entry<VariableReferenceExpression, RowExpression> entry : assignments.getMap().entrySet()) {\n            List<ProjectionContext> rewritten = entry.getValue().accept(new Visitor(functionAndTypeManager, variableAllocator), null);\n            if (rewritten.isEmpty()) {\n                assignmentProjections.add(ImmutableList.of(new ProjectionContext(ImmutableMap.of(entry.getKey(), entry.getValue()), false)));","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/iterative/rule/PlanRemoteProjections.java#L77-L113","documentation":"Remote (server-side external) functions are gated behind a session/config flag. PlanRemoteProjections detects remote-function calls in a projection; if any exist but the remote-functions feature is disabled, it throws GENERIC_USER_ERROR telling the user to enable the feature.","triggerScenarios":"A query projection references an external/remote function (matched by ExternalCallExpressionChecker) while 'remote-functions-enabled' is false in the session or config.","commonSituations":"Calling remote functions on a cluster without the flag enabled; config migrated from a cluster where remote functions were on; testing AI/remote UDFs without enabling the feature.","solutions":["Enable it: SET SESSION remote_functions_enabled = true","Set remote-functions-enabled=true in the coordinator config.properties","Remove or replace the remote function with a local UDF if the feature cannot be enabled"],"exampleFix":"// before\nSELECT remote_model_classify(text) FROM messages; -- flag off\n// after\nSET SESSION remote_functions_enabled = true;\nSELECT remote_model_classify(text) FROM messages;","handlingStrategy":"try-catch","validationCode":"SHOW SESSION LIKE 'remote_functions_enabled';","typeGuard":"null","tryCatchPattern":"try {\n    return query(sql);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == GENERIC_USER_ERROR.toErrorCode() && e.getMessage().contains(\"Remote functions\")) {\n        setSessionProperty(\"remote_functions_enabled\", \"true\");\n        return retryQuery(sql);\n    }\n    throw e;\n}","preventionTips":["Enable remote-functions-enabled on clusters that will run remote UDFs","Check the flag in session setup code before issuing remote-function queries","Document which functions are remote so users know the dependency"],"tags":["remote-functions","feature-flag","projection"],"backgroundTag":"feature-not-enabled","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"}