{"record":{"id":"39e562c97b580f0f","repo":"apache/iceberg","slug":"unsupported-spark-view-dependency-dependency-ge","errorCode":null,"errorMessage":"Unsupported Spark view dependency: ${dependency.getClass().getName()}","messagePattern":"Unsupported Spark view dependency: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewDependenciesParser.java","lineNumber":61,"sourceCode":"  private static final String TABLE = \"table\";\n  private static final String FUNCTION = \"function\";\n  private static final ObjectMapper MAPPER = new ObjectMapper();\n\n  private SparkViewDependenciesParser() {}\n\n  static String toJson(DependencyList dependencyList) {\n    ArrayNode dependenciesNode = MAPPER.createArrayNode();\n    for (Dependency dependency : dependencyList.dependencies()) {\n      ObjectNode dependencyNode = dependenciesNode.addObject();\n      String[] nameParts;\n      if (dependency instanceof TableDependency) {\n        dependencyNode.put(TYPE, TABLE);\n        nameParts = ((TableDependency) dependency).nameParts();\n      } else if (dependency instanceof FunctionDependency) {\n        dependencyNode.put(TYPE, FUNCTION);\n        nameParts = ((FunctionDependency) dependency).nameParts();\n      } else {\n        throw new IllegalArgumentException(\n            \"Unsupported Spark view dependency: \" + dependency.getClass().getName());\n      }\n\n      ArrayNode namePartsNode = dependencyNode.putArray(NAME_PARTS);\n      for (String namePart : nameParts) {\n        namePartsNode.add(namePart);\n      }\n    }\n\n    try {\n      return MAPPER.writeValueAsString(dependenciesNode);\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to write Spark view dependencies\", e);\n    }\n  }\n\n  static DependencyList fromJson(String json) {\n    JsonNode node;","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewDependenciesParser.java#L43-L79","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only build views with table and function dependencies on this connector version","Upgrade the Iceberg Spark runtime to a version supporting the new dependency type","If you own the code, add a case for the new Dependency subtype in toJson()","Inspect the class name in the message to identify which dependency kind leaked in"],"exampleFix":"// before\nDependency d = new CustomDependency(nameParts); // throws in toJson\n// after\nDependency d = Dependency.table(nameParts); // supported type","handlingStrategy":"validation","validationCode":"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\");","typeGuard":"boolean serializableDependency(Dependency d) { return d instanceof TableDependency || d instanceof FunctionDependency; }","tryCatchPattern":"try { json = SparkViewDependenciesParser.toJson(deps); } catch (IllegalArgumentException e) { log.error(\"Dependency type not serializable\", e); throw e; }","preventionTips":["Build views only with table/function dependencies","Keep connector upgraded when Spark adds new dependency kinds","Check the class name in the message to identify unsupported subtype"],"tags":["spark","iceberg","views","serialization","illegal-argument"],"backgroundTag":"unsupported-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}