{"record":{"id":"35c90447a06c52de","repo":"prestodb/presto","slug":"not-supported-35c904","errorCode":"NOT_SUPPORTED","errorMessage":"External functions in %s is not supported: %s","messagePattern":"External functions in (.+?) is not supported: (.+?)","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/Analyzer.java","lineNumber":169,"sourceCode":"        List<FunctionCall> windowExpressions = extractWindowFunctions(ImmutableList.of(predicate));\n\n        List<GroupingOperation> groupingOperations = extractExpressions(ImmutableList.of(predicate), GroupingOperation.class);\n\n        List<Expression> found = Stream.concat(\n                aggregates.stream(),\n                Stream.concat(windowExpressions.stream(), groupingOperations.stream()))\n                .collect(toImmutableList());\n\n        if (!found.isEmpty()) {\n            throw new SemanticException(CANNOT_HAVE_AGGREGATIONS_WINDOWS_OR_GROUPING, predicate, \"%s cannot contain aggregations, window functions or grouping operations: %s\", clause, found);\n        }\n    }\n\n    static void verifyNoExternalFunctions(Map<NodeRef<FunctionCall>, FunctionHandle> functionHandles, FunctionAndTypeResolver functionAndTypeResolver, Expression predicate, String clause)\n    {\n        List<FunctionCall> externalFunctions = extractExternalFunctions(functionHandles, ImmutableList.of(predicate), functionAndTypeResolver);\n        if (!externalFunctions.isEmpty()) {\n            throw new SemanticException(NOT_SUPPORTED, predicate, \"External functions in %s is not supported: %s\", clause, externalFunctions);\n        }\n    }\n}\n","sourceCodeStart":151,"sourceCodeEnd":173,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/Analyzer.java#L151-L173","documentation":"Presto does not allow external (declared/remote) functions in certain predicates/clauses. verifyNoExternalFunctions extracts external function calls from the analyzed function handles for the given predicate expression and throws NOT_SUPPORTED listing them if any exist.","triggerScenarios":"Using a connector-declared external/remote scalar function inside a predicate clause (e.g. WHERE/HAVING/measure filter) that the analyzer validates via this check.","commonSituations":"Queries mixing external functions from federated connectors into pushdownable predicates; version/connector changes introducing external functions into previously plain expressions.","solutions":["Replace the external function with a built-in Presto function in the predicate.","Move the external-function predicate to an outer query so the restricted clause contains only supported functions.","Precompute the external function result in a subquery/CTE or materialize it into a column.","If supported, force the connector to expose a native function instead of an external one."],"exampleFix":"// before\nSELECT * FROM t WHERE external_fn(x) > 0;\n// after\nSELECT * FROM (SELECT *, external_fn(x) AS f FROM t) WHERE f > 0;","handlingStrategy":"validation","validationCode":"// scan predicate functions and reject external ones\nextractFunctions(predicate).forEach(fn -> {\n    if (isExternalFunction(fn, functionAndTypeResolver)) {\n        throw new IllegalArgumentException(\"External function not allowed in \" + clause + \": \" + fn);\n    }\n});","typeGuard":null,"tryCatchPattern":"try { runQuery(sql); } catch (SemanticException e) { if (e.getCode() == NOT_SUPPORTED && e.getMessage().contains(\"External functions\")) { /* replace or hoist external fn */ } throw e; }","preventionTips":["Keep external/connector functions out of pushdown predicates.","Use built-in Presto functions where possible.","Wrap external-function computations in subqueries/CTEs.","Pin connector versions and test federated predicates before upgrade."],"tags":["sql","external-functions","not-supported"],"backgroundTag":"external-function-not-supported","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"}