apache/iceberg · error · UnsupportedOperationException

Unsupported aggregate type:

Error message

Unsupported aggregate type: 

What it means

BoundAggregate.describe() (and related string/eval switches) only recognizes COUNT, COUNT_IF, MAX, and MIN aggregate operations. Any other Operation reaching the switch hits the default branch and throws this UnsupportedOperationException.

Source

Thrown at api/src/main/java/org/apache/iceberg/expressions/BoundAggregate.java:93

    } else {
      return ref().name();
    }
  }

  public String describe() {
    switch (op()) {
      case COUNT_STAR:
        return "count(*)";
      case COUNT:
        return "count(" + ExpressionUtil.describe(term()) + ")";
      case COUNT_NULL:
        return "count_if(" + ExpressionUtil.describe(term()) + " is null)";
      case MAX:
        return "max(" + ExpressionUtil.describe(term()) + ")";
      case MIN:
        return "min(" + ExpressionUtil.describe(term()) + ")";
      default:
        throw new UnsupportedOperationException("Unsupported aggregate type: " + op());
    }
  }

  <V> boolean safeContainsKey(Map<Integer, V> map, int key) {
    if (map == null) {
      return false;
    }
    return map.containsKey(key);
  }

  <V> V safeGet(Map<Integer, V> map, int key) {
    return safeGet(map, key, null);
  }

  <V> V safeGet(Map<Integer, V> map, int key, V defaultValue) {
    if (map != null) {
      return map.getOrDefault(key, defaultValue);
    }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Use only COUNT, COUNT_IF, MAX, MIN operations in aggregate expressions
  2. Validate the operation before constructing/binding the aggregate
  3. Update Iceberg version if a newer aggregate op is required
  4. Fix parser/visitor code that maps predicate operations to aggregates

Example fix

// before
Expression agg = Expressions.aggregate(Operation.SUM, Expressions.column("x")); // unsupported
// after
Expression agg = Expressions.aggregate(Operation.MAX, Expressions.column("x"));
Defensive patterns

Strategy: validation

Validate before calling

Preconditions.checkArgument(Set.of(Operation.COUNT, Operation.MAX, Operation.MIN).contains(op), "Unsupported aggregate op: %s", op);

Prevention

When it happens

Trigger: Constructing a BoundAggregate with an operation other than COUNT/COUNT_IF/MAX/MIN (e.g. SUM or a predicate operation) and evaluating or describing it; internal mis-binding that produces a bound aggregate for a non-aggregate operation.

Common situations: Custom ExpressionParser emitting aggregates with unsupported ops; user code building Expressions.aggregate with a wrong Operation enum; version skew where new ops lack describe/eval support.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/42ae83cca7b04c15. Report an issue: GitHub.