prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

Aggregate Function is not supported in RestBasedFunctionNamespaceManager

What it means

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.

Source

Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestBasedFunctionNamespaceManager.java:79

    private final RestBasedFunctionApis restApis;
    private final List<SqlInvokedFunction> latestFunctions = new ArrayList<>();
    private final AtomicReference<Optional<String>> cachedETag = new AtomicReference<>(Optional.empty());

    @Inject
    public RestBasedFunctionNamespaceManager(
            @ServingCatalog String catalogName,
            SqlFunctionExecutors sqlFunctionExecutors,
            SqlInvokedFunctionNamespaceManagerConfig config,
            RestBasedFunctionApis restApis)
    {
        super(catalogName, sqlFunctionExecutors, config);
        this.restApis = requireNonNull(restApis, "restApis is null");
    }

    @Override
    public final AggregationFunctionImplementation getAggregateFunctionImplementation(FunctionHandle functionHandle, TypeManager typeManager)
    {
        throw new PrestoException(NOT_SUPPORTED, "Aggregate Function is not supported in RestBasedFunctionNamespaceManager");
    }

    private List<SqlInvokedFunction> getLatestFunctions()
    {
        // Check if the function list has been modified.
        String newETag = restApis.getFunctionsETag();
        Optional<String> currentETag = cachedETag.get();
        if (newETag != null && currentETag.isPresent() && cachedETag.get().equals(newETag)) {
            return latestFunctions;
        }

        // Clear cached list of functions and get the latest list.
        latestFunctions.clear();
        UdfFunctionSignatureMap udfFunctionSignatureMap = restApis.getAllFunctions();
        if (udfFunctionSignatureMap == null || udfFunctionSignatureMap.isEmpty()) {
            return ImmutableList.of();
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use only scalar SQL functions via the REST-backed catalog; implement aggregates as built-in or in a manager that supports them
  2. Rewrite the query to use built-in aggregate functions (sum, avg, array_agg, etc.) instead of a custom aggregate
  3. Host the aggregate function in a namespace manager that implements getAggregateFunctionImplementation (e.g. the plugin-based or MySQL path)

Example fix

// before
SELECT custom_agg(x) FROM t GROUP BY k  -- REST UDF used as aggregate
// after
SELECT sum(x) FROM t GROUP BY k  -- built-in aggregate, or keep custom_agg scalar
Defensive patterns

Strategy: try-catch

Validate before calling

// Only invoke REST-managed functions in scalar positions
if (isAggregateInvocation(functionHandle) && manager instanceof RestBasedFunctionNamespaceManager) {
    throw new UnsupportedOperationException("Aggregates unsupported via REST function namespace");
}

Try / catch

try {
    impl = manager.getAggregateFunctionImplementation(handle, typeManager);
} catch (PrestoException e) {
    if (e.getErrorCode().getCode() == NOT_SUPPORTED.toErrorCode().getCode()) {
        // rewrite query with built-in aggregates
    } else throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: Users assuming REST-published UDFs support aggregate semantics; queries using GROUP BY with custom functions; misconfigured catalogs routing aggregate handles to the REST manager.

Understand the failure class

Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/4f83c8f6a9b28842. Report an issue: GitHub.