apache/beam · error · IllegalArgumentException

No implementation of aggregate function

Error message

No implementation of aggregate function ${functionFullName} found in ${jarPath}. 1. Create a class implementing UdfProvider and annotate it with @AutoService(UdfProvider.class). 2. Add function ${functionFullName} to the class's userDefinedAggregateFunctions implementation.

What it means

JavaUdfLoader.loadAggregateFunction() throws IllegalArgumentException when the loaded jar's UdfProvider does not export an aggregate function with the requested path. The jar loads fine but FunctionDefinitions.aggregateFunctions() has no entry for functionPath; the message includes remediation steps about implementing UdfProvider and adding the function to userDefinedAggregateFunctions().

Solutions

  1. Ensure the aggregate is registered by overriding userDefinedAggregateFunctions() in the UdfProvider implementation.
  2. Annotate the provider class with @AutoService(UdfProvider.class) and rebuild the jar.
  3. Match the function name/path exactly to the registry key.
  4. Redeploy/replace the jar at the path used by the query.

Example fix

// before (only scalars registered)
public Map<String, ScalarFn> userDefinedScalarFunctions() {...}
// after
@Override
public Map<String, AggregateFn> userDefinedAggregateFunctions() {
  return ImmutableMap.of("myagg", new MyAggregateFn());
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!new File(jarPath).isFile()) {
  throw new IllegalArgumentException("UDF jar not found: " + jarPath);
}

Try / catch

try {
  AggregateFn fn = udfLoader.loadAggregateFunction(fnPath, jarPath);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("No implementation of aggregate function")) {
    LOG.error("Aggregate {} not registered in {}", fnPath, jarPath);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling loadAggregateFunction(List<String> functionPath, String jarPath) (e.g. from getAggregateFn or the SQL shell during a GROUP BY with a custom aggregate) when the jar's provider lacks that aggregate function.

Common situations: Typo in the aggregate function name; the provider implements only userDefinedScalarFunctions, not userDefinedAggregateFunctions; missing @AutoService(UdfProvider.class); stale jar deployed before the aggregate was added.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/5dfa17069ebe58fa. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/JavaUdfLoader.java:101

                UdfProvider.class.getSimpleName(),
                functionFullName));
      }
      return functionDefinitions.scalarFunctions().get(functionPath);
    } catch (IOException e) {
      throw new RuntimeException(
          String.format(
              "Failed to load user-defined scalar function %s from %s", functionFullName, jarPath),
          e);
    }
  }

  /** Load a user-defined aggregate function from the specified jar. */
  public AggregateFn loadAggregateFunction(List<String> functionPath, String jarPath) {
    String functionFullName = String.join(".", functionPath);
    try {
      FunctionDefinitions functionDefinitions = loadJar(jarPath);
      if (!functionDefinitions.aggregateFunctions().containsKey(functionPath)) {
        throw new IllegalArgumentException(
            String.format(
                "No implementation of aggregate function %s found in %s.%n"
                    + " 1. Create a class implementing %s and annotate it with @AutoService(%s.class).%n"
                    + " 2. Add function %s to the class's userDefinedAggregateFunctions implementation.",
                functionFullName,
                jarPath,
                UdfProvider.class.getSimpleName(),
                UdfProvider.class.getSimpleName(),
                functionFullName));
      }
      return functionDefinitions.aggregateFunctions().get(functionPath);
    } catch (IOException e) {
      throw new RuntimeException(
          String.format(
              "Failed to load user-defined aggregate function %s from %s",
              functionFullName, jarPath),
          e);
    }

View on GitHub (pinned to 12126d8942)