apache/iceberg · error · UncheckedIOException

Failed to parse Spark view dependencies

Error message

Failed to parse Spark view dependencies

What it means

SparkViewDependenciesParser.fromJson() parses the view dependencies JSON string. If Jackson cannot read the tree, the IOException is rethrown as UncheckedIOException('Failed to parse Spark view dependencies'). It means the stored metadata JSON is malformed, not merely semantically invalid.

Source

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

      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;
    try {
      node = MAPPER.readTree(json);
    } catch (IOException e) {
      throw new UncheckedIOException("Failed to parse Spark view dependencies", e);
    }

    Preconditions.checkArgument(
        node.isArray(), "Cannot parse Spark view dependencies from non-array: %s", node);
    ImmutableList.Builder<Dependency> dependenciesBuilder = ImmutableList.builder();
    for (JsonNode dependency : node) {
      String type = string(TYPE, dependency);
      String[] nameParts = stringArray(NAME_PARTS, dependency);
      switch (type) {
        case TABLE:
          dependenciesBuilder.add(Dependency.table(nameParts));
          break;
        case FUNCTION:
          dependenciesBuilder.add(Dependency.function(nameParts));
          break;
        default:
          throw new IllegalArgumentException("Unsupported Spark view dependency type: " + type);
      }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect and repair the view metadata JSON so it is a valid JSON array
  2. Recreate the view if its metadata is unrecoverable
  3. Restore from backup or re-register the view with correct metadata location
  4. Validate the JSON with an external parser to pinpoint the syntax error

Example fix

// before
// metadata: "[{"type":"table","name-parts":["db","tbl"]"  (truncated)
// after
// metadata: "[{"type":"table","name-parts":["db","tbl"]}]"  (valid array)
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-validate
if (json == null || json.isBlank()) throw new IllegalArgumentException("View dependencies JSON is empty");

Try / catch

try { deps = SparkViewDependenciesParser.fromJson(json); } catch (UncheckedIOException e) { log.error("Corrupt view dependencies JSON: {}", json, e); throw new IllegalStateException("View metadata unreadable", e); }

Prevention

When it happens

Trigger: Loading a Spark view whose persisted dependency JSON is truncated, corrupted, or hand-edited; MAPPER.readTree(json) throwing on invalid JSON syntax.

Common situations: Manually edited metadata files; interrupted writes leaving partial JSON; version upgrades where an older writer produced incompatible content.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


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