apache/iceberg · error · UnsupportedOperationException

AboveMax has no value

Error message

AboveMax has no value

What it means

AboveMax is a sentinel Literal produced when converting a literal that exceeds the maximum representable value of a target type (Literal.to(Type)). It has no concrete value, so calling value() throws UnsupportedOperationException. The sentinel exists so comparisons like 'x > AboveMax' can be recognized as always-false without a real value.

Source

Thrown at api/src/main/java/org/apache/iceberg/expressions/Literals.java:183

    ComparableLiteral(C value) {
      super(value);
    }

    @Override
    @SuppressWarnings("unchecked")
    public Comparator<C> comparator() {
      return (Comparator<C>) CMP;
    }
  }

  static class AboveMax<T> implements Literal<T> {
    private static final AboveMax INSTANCE = new AboveMax();

    private AboveMax() {}

    @Override
    public T value() {
      throw new UnsupportedOperationException("AboveMax has no value");
    }

    @Override
    public <X> Literal<X> to(Type type) {
      throw new UnsupportedOperationException("Cannot change the type of AboveMax");
    }

    @Override
    public Comparator<T> comparator() {
      throw new UnsupportedOperationException("AboveMax has no comparator");
    }

    @Override
    public String toString() {
      return "aboveMax";
    }
  }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Check for AboveMax/BelowMin (instanceof Literals.AboveMax / Literals.BelowMin) before calling value() and treat them as +/- infinity
  2. Use the literal's comparator or special-case the comparison instead of extracting a value
  3. Recompute the literal in a wider type so a concrete value exists

Example fix

// before
Object v = converted.value(); // throws for AboveMax
// after
if (converted instanceof Literals.AboveMax) { return alwaysFalse(); }
Object v = converted.value();
Defensive patterns

Strategy: type-guard

Validate before calling

if (lit instanceof Literals.AboveMax || lit instanceof Literals.BelowMin) {
  // handle as +/- infinity; do not call value()
}

Type guard

static boolean hasConcreteValue(Literal<?> lit) {
  return !(lit instanceof Literals.AboveMax) && !(lit instanceof Literals.BelowMin);
}

Try / catch

Object v;
try {
  v = lit.value();
} catch (UnsupportedOperationException e) {
  if (e.getMessage().contains("AboveMax has no value")) {
    return treatAsPositiveInfinity();
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling value() on the literal returned by Literals.aboveMax() or by literal.to(smallType) where the original value overflowed the target type — e.g. in expression evaluation, bound extraction, or statistics code that assumes every literal has a value.

Common situations: Narrowing a Long literal to Integer or a Double literal to Float where the value exceeds the target range, then attempting to read the value for lower/upper bound computation.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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