{"record":{"id":"3fd0caa83485ca51","repo":"apache/iceberg","slug":"failed-to-parse-spark-view-query-column-names","errorCode":null,"errorMessage":"Failed to parse Spark view query column names","messagePattern":"Failed to parse Spark view query column names","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewQueryColumnNamesParser.java","lineNumber":60,"sourceCode":"    try {\n      JsonNode node = MAPPER.readTree(json);\n      Preconditions.checkArgument(\n          node != null && node.isArray(),\n          \"Cannot parse Spark view query column names from non-array: %s\",\n          node);\n      String[] columnNames = new String[node.size()];\n      for (int index = 0; index < node.size(); index += 1) {\n        JsonNode columnName = node.get(index);\n        Preconditions.checkArgument(\n            columnName.isTextual(),\n            \"Cannot parse Spark view query column name from non-string: %s\",\n            columnName);\n        columnNames[index] = columnName.asText();\n      }\n\n      return columnNames;\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to parse Spark view query column names\", e);\n    }\n  }\n}\n","sourceCodeStart":42,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkViewQueryColumnNamesParser.java#L42-L64","documentation":"This UncheckedIOException is thrown by SparkViewQueryQueryColumnNamesParser.fromJson when Jackson fails to read the JSON representation of a Spark view query's column names. It wraps the underlying IOException so callers get a runtime exception with a clear message about what JSON structure failed to parse.","triggerScenarios":"Calling SparkViewQueryQueryColumnNamesParser.fromJson(String) with malformed JSON, a JSON node that is not the expected array of text values, or JSON that cannot be deserialized by JsonUtil.mapper().","commonSituations":"Corrupted or hand-edited view metadata JSON, version drift where the stored view representation changed shape (e.g. older/newer Spark writing different JSON), or passing a non-JSON string recovered from a catalog property.","solutions":["Validate the JSON string parses to the expected array of column names before calling fromJson","Catch UncheckedIOException at the call site and log/inspect the offending JSON payload","Check that the view metadata was written by a compatible Iceberg/Spark version and rewrite the view if it is corrupted"],"exampleFix":"// before\nString[] cols = SparkViewQueryQueryColumnNamesParser.fromJson(json);\n// after\nString[] cols;\ntry {\n  cols = SparkViewQueryQueryColumnNamesParser.fromJson(json);\n} catch (UncheckedIOException e) {\n  LOG.error(\"Bad view query column names JSON: {}\", json, e);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Java\nif (json == null || !json.trim().startsWith(\"[\")) {\n  throw new IllegalArgumentException(\"Expected JSON array of column names, got: \" + json);\n}\nJsonUtil.mapper().readTree(json); // pre-validate parseability","typeGuard":"boolean isColumnNameNamesJson(String json) {\n  try { return json != null && JsonUtil.mapper().readTree(json).isArray(); }\n  catch (IOException e) { return false; }\n}","tryCatchPattern":"try {\n  String[] cols = SparkViewQueryQueryColumnNamesParser.fromJson(json);\n} catch (UncheckedIOException e) {\n  // e.getCause() is the Jackson IOException; inspect/log json\n  throw new IllegalArgumentException(\"Corrupt view column names JSON\", e);\n}","preventionTips":["Never hand-edit view metadata JSON","Round-trip toJson/fromJson in tests after Iceberg upgrades","Validate JSON shape before parsing"],"tags":["json","spark","view-metadata"],"backgroundTag":"json-parse-error","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}