apache/iceberg · error · UnsupportedOperationException

Histogram is not supported.

Error message

Histogram is not supported.

What it means

MetricsContext.histogram(String) is a default stub throwing UnsupportedOperationException('Histogram is not supported.'). The base interface offers no histogram support by default; implementations must override it to provide one.

Source

Thrown at api/src/main/java/org/apache/iceberg/metrics/MetricsContext.java:153

   * @return a {@link org.apache.iceberg.metrics.Counter} implementation
   */
  default org.apache.iceberg.metrics.Counter counter(String name) {
    return counter(name, Unit.COUNT);
  }

  /**
   * Get a named timer.
   *
   * @param name name of the metric
   * @param unit the time unit designation of the metric
   * @return a timer implementation
   */
  default Timer timer(String name, TimeUnit unit) {
    throw new UnsupportedOperationException("Timer is not supported.");
  }

  default Histogram histogram(String name) {
    throw new UnsupportedOperationException("Histogram is not supported.");
  }

  /**
   * Utility method for producing no metrics.
   *
   * @return a non-recording metrics context
   */
  static MetricsContext nullMetrics() {
    return new MetricsContext() {

      @Override
      public Timer timer(String name, TimeUnit unit) {
        return Timer.NOOP;
      }

      @Override
      @SuppressWarnings("unchecked")
      public <T extends Number> Counter<T> counter(String name, Class<T> type, Unit unit) {

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Use a MetricsContext implementation that overrides histogram()
  2. Override histogram(String) in your custom context
  3. If histograms aren't needed, avoid calling this method or return a NOOP histogram
  4. Feature-check before requesting a histogram

Example fix

// before
Histogram h = ctx.histogram("distribution"); // throws
// after
Histogram h = supportedContext.histogram("distribution");
Defensive patterns

Strategy: fallback

Try / catch

try { histogram } catch (UnsupportedOperationException e) { skip }

Prevention

When it happens

Trigger: Calling histogram(name) on a MetricsContext that doesn't override it, then recording values into the histogram.

Common situations: Custom MetricsContext implementations lacking histogram support; code assuming all contexts (including minimal test contexts) provide histograms.

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/954147433b150c08. Report an issue: GitHub.