apache/iceberg · error · UnsupportedOperationException

Resolving a sql with a given dialect is not supported

Error message

Resolving a sql with a given dialect is not supported

What it means

View.sqlFor(String dialect) is a default interface method that throws UnsupportedOperationException. It resolves the SQLViewRepresentation for a given engine dialect (e.g. "spark", "trino"); implementations without view-version resolution support throw instead of returning null.

Source

Thrown at api/src/main/java/org/apache/iceberg/view/View.java:132

  }

  /**
   * Returns the view's UUID
   *
   * @return the view's UUID
   */
  default UUID uuid() {
    throw new UnsupportedOperationException("Retrieving a view's uuid is not supported");
  }

  /**
   * Returns the view representation for the given SQL dialect
   *
   * @return the view representation for the given SQL dialect, or null if no representation could
   *     be resolved
   */
  default SQLViewRepresentation sqlFor(String dialect) {
    throw new UnsupportedOperationException(
        "Resolving a sql with a given dialect is not supported");
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Use a View implementation backed by view metadata that overrides sqlFor().
  2. Iterate view.currentVersion().representations() manually and match the dialect case-insensitively yourself.
  3. Handle the null return documented by the API by overriding sqlFor in your implementation rather than relying on the default.

Example fix

// before
SQLViewRepresentation repr = view.sqlFor(dialect);

// after
SQLViewRepresentation repr = view.currentVersion().representations().stream()
    .filter(r -> r.dialect().equalsIgnoreCase(dialect))
    .findFirst()
    .orElse(null);
Defensive patterns

Strategy: fallback

Validate before calling

boolean canResolve = view.currentVersion() != null && !view.currentVersion().representations().isEmpty();

Try / catch

try { return view.sqlFor(dialect); } catch (UnsupportedOperationException e) { return resolveManually(view.currentVersion().representations(), dialect); }

Prevention

When it happens

Trigger: Calling view.sqlFor("spark") (often from Spark SQL rendering of views, e.g. sqlRepr) on a View implementation that has not overridden sqlFor().

Common situations: Rendering a view's stored SQL in a query engine or tooling; using a stub View in unit tests of dialect resolution.

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