apache/iceberg · error · IllegalArgumentException

Unsupported Spark view dependency: ${dependency.getClass().g

Error message

Unsupported Spark view dependency: ${dependency.getClass().getName()}

What it means

SparkViewDependenciesParser.toJson() serializes view dependencies (TableDependency, FunctionDependency) into JSON. A dependency of any other type hits the default branch and throws IllegalArgumentException naming the offending class, since only table and function dependencies are representable in the view metadata JSON.

Source

Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewDependenciesParser.java:61

  private static final String TABLE = "table";
  private static final String FUNCTION = "function";
  private static final ObjectMapper MAPPER = new ObjectMapper();

  private SparkViewDependenciesParser() {}

  static String toJson(DependencyList dependencyList) {
    ArrayNode dependenciesNode = MAPPER.createArrayNode();
    for (Dependency dependency : dependencyList.dependencies()) {
      ObjectNode dependencyNode = dependenciesNode.addObject();
      String[] nameParts;
      if (dependency instanceof TableDependency) {
        dependencyNode.put(TYPE, TABLE);
        nameParts = ((TableDependency) dependency).nameParts();
      } else if (dependency instanceof FunctionDependency) {
        dependencyNode.put(TYPE, FUNCTION);
        nameParts = ((FunctionDependency) dependency).nameParts();
      } else {
        throw new IllegalArgumentException(
            "Unsupported Spark view dependency: " + dependency.getClass().getName());
      }

      ArrayNode namePartsNode = dependencyNode.putArray(NAME_PARTS);
      for (String namePart : nameParts) {
        namePartsNode.add(namePart);
      }
    }

    try {
      return MAPPER.writeValueAsString(dependenciesNode);
    } catch (IOException e) {
      throw new UncheckedIOException("Failed to write Spark view dependencies", e);
    }
  }

  static DependencyList fromJson(String json) {
    JsonNode node;

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Only build views with table and function dependencies on this connector version
  2. Upgrade the Iceberg Spark runtime to a version supporting the new dependency type
  3. If you own the code, add a case for the new Dependency subtype in toJson()
  4. Inspect the class name in the message to identify which dependency kind leaked in

Example fix

// before
Dependency d = new CustomDependency(nameParts); // throws in toJson
// after
Dependency d = Dependency.table(nameParts); // supported type
Defensive patterns

Strategy: validation

Validate before calling

boolean allSupported = Arrays.stream(deps.dependencies()).allMatch(d -> d instanceof TableDependency || d instanceof FunctionDependency); if (!allSupported) throw new IllegalArgumentException("View contains an unsupported dependency type");

Type guard

boolean serializableDependency(Dependency d) { return d instanceof TableDependency || d instanceof FunctionDependency; }

Try / catch

try { json = SparkViewDependenciesParser.toJson(deps); } catch (IllegalArgumentException e) { log.error("Dependency type not serializable", e); throw e; }

Prevention

When it happens

Trigger: Serializing a Spark view whose DependencyList contains a Dependency subclass other than TableDependency or FunctionDependency — e.g. a new dependency type introduced by Spark or a custom extension.

Common situations: Creating/altering views that reference newly supported objects (e.g. model/other entities) with an older Iceberg connector; custom Dependency implementations passed into the view metadata path.

Related errors


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