{"record":{"id":"4f83c8f6a9b28842","repo":"prestodb/presto","slug":"not-supported-4f83c8","errorCode":"NOT_SUPPORTED","errorMessage":"Aggregate Function is not supported in RestBasedFunctionNamespaceManager","messagePattern":"Aggregate Function is not supported in RestBasedFunctionNamespaceManager","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestBasedFunctionNamespaceManager.java","lineNumber":79,"sourceCode":"    private final RestBasedFunctionApis restApis;\n    private final List<SqlInvokedFunction> latestFunctions = new ArrayList<>();\n    private final AtomicReference<Optional<String>> cachedETag = new AtomicReference<>(Optional.empty());\n\n    @Inject\n    public RestBasedFunctionNamespaceManager(\n            @ServingCatalog String catalogName,\n            SqlFunctionExecutors sqlFunctionExecutors,\n            SqlInvokedFunctionNamespaceManagerConfig config,\n            RestBasedFunctionApis restApis)\n    {\n        super(catalogName, sqlFunctionExecutors, config);\n        this.restApis = requireNonNull(restApis, \"restApis is null\");\n    }\n\n    @Override\n    public final AggregationFunctionImplementation getAggregateFunctionImplementation(FunctionHandle functionHandle, TypeManager typeManager)\n    {\n        throw new PrestoException(NOT_SUPPORTED, \"Aggregate Function is not supported in RestBasedFunctionNamespaceManager\");\n    }\n\n    private List<SqlInvokedFunction> getLatestFunctions()\n    {\n        // Check if the function list has been modified.\n        String newETag = restApis.getFunctionsETag();\n        Optional<String> currentETag = cachedETag.get();\n        if (newETag != null && currentETag.isPresent() && cachedETag.get().equals(newETag)) {\n            return latestFunctions;\n        }\n\n        // Clear cached list of functions and get the latest list.\n        latestFunctions.clear();\n        UdfFunctionSignatureMap udfFunctionSignatureMap = restApis.getAllFunctions();\n        if (udfFunctionSignatureMap == null || udfFunctionSignatureMap.isEmpty()) {\n            return ImmutableList.of();\n        }\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestBasedFunctionNamespaceManager.java#L61-L97","documentation":"RestBasedFunctionNamespaceManager.getAggregateFunctionImplementation is an explicitly unsupported override: the REST function namespace only serves scalar SQL UDFs, so requesting an aggregate function implementation throws NOT_SUPPORTED. The manager cannot produce AggregationFunctionImplementation for handles resolved against the REST backend.","triggerScenarios":"Executing a query that plans an aggregation whose function handle belongs to the REST-based function namespace (e.g. invoking a REST-registered UDF as an aggregate, or binding an aggregate FunctionHandle to this manager).","commonSituations":"Users assuming REST-published UDFs support aggregate semantics; queries using GROUP BY with custom functions; misconfigured catalogs routing aggregate handles to the REST manager.","solutions":["Use only scalar SQL functions via the REST-backed catalog; implement aggregates as built-in or in a manager that supports them","Rewrite the query to use built-in aggregate functions (sum, avg, array_agg, etc.) instead of a custom aggregate","Host the aggregate function in a namespace manager that implements getAggregateFunctionImplementation (e.g. the plugin-based or MySQL path)"],"exampleFix":"// before\nSELECT custom_agg(x) FROM t GROUP BY k  -- REST UDF used as aggregate\n// after\nSELECT sum(x) FROM t GROUP BY k  -- built-in aggregate, or keep custom_agg scalar","handlingStrategy":"try-catch","validationCode":"// Only invoke REST-managed functions in scalar positions\nif (isAggregateInvocation(functionHandle) && manager instanceof RestBasedFunctionNamespaceManager) {\n    throw new UnsupportedOperationException(\"Aggregates unsupported via REST function namespace\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    impl = manager.getAggregateFunctionImplementation(handle, typeManager);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == NOT_SUPPORTED.toErrorCode().getCode()) {\n        // rewrite query with built-in aggregates\n    } else throw e;\n}","preventionTips":["Publish only scalar UDFs to REST function namespaces","Train users to use built-in aggregates for GROUP BY queries","Keep custom aggregates in managers that implement getAggregateFunctionImplementation"],"tags":["not-supported","aggregate","rest","function-namespace"],"backgroundTag":"operation-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"}