{"record":{"id":"db57d0d22f7d0456","repo":"apache/iceberg","slug":"cannot-serialize-unsupported-view-representation","errorCode":null,"errorMessage":"Cannot serialize unsupported view representation: %s","messagePattern":"Cannot serialize unsupported view representation: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/view/ViewRepresentationParser.java","lineNumber":42,"sourceCode":"import java.util.Locale;\nimport org.apache.iceberg.relocated.com.google.common.base.Preconditions;\nimport org.apache.iceberg.util.JsonUtil;\n\nclass ViewRepresentationParser {\n  static final String TYPE = \"type\";\n\n  private ViewRepresentationParser() {}\n\n  static void toJson(ViewRepresentation representation, JsonGenerator generator)\n      throws IOException {\n    Preconditions.checkArgument(representation != null, \"Invalid view representation: null\");\n    switch (representation.type().toLowerCase(Locale.ROOT)) {\n      case ViewRepresentation.Type.SQL:\n        SQLViewRepresentationParser.toJson((SQLViewRepresentation) representation, generator);\n        break;\n\n      default:\n        throw new UnsupportedOperationException(\n            String.format(\n                \"Cannot serialize unsupported view representation: %s\", representation.type()));\n    }\n  }\n\n  static String toJson(ViewRepresentation entry) {\n    return JsonUtil.generate(gen -> toJson(entry, gen), false);\n  }\n\n  static ViewRepresentation fromJson(String json) {\n    return JsonUtil.parse(json, ViewRepresentationParser::fromJson);\n  }\n\n  static ViewRepresentation fromJson(JsonNode node) {\n    Preconditions.checkArgument(node != null, \"Cannot parse view representation from null object\");\n    Preconditions.checkArgument(\n        node.isObject(), \"Cannot parse view representation from non-object: %s\", node);\n    String type = JsonUtil.getString(TYPE, node).toLowerCase(Locale.ROOT);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/view/ViewRepresentationParser.java#L24-L60","documentation":"ViewRepresentationParser.toJson only knows how to serialize SQL view representations. If a ViewRepresentation has any other type (e.g. a future or custom dialect type), serialization throws UnsupportedOperationException — the parser version predates the representation type.","triggerScenarios":"Serializing a ViewRepresentation whose type() is not \"sql\" — typically a view metadata file produced by a newer Iceberg version or an extension adding a non-SQL representation.","commonSituations":"Downgraded Iceberg version reading metadata written by a newer release; custom view representations from vendor extensions; corrupted type strings that fail the lowercase SQL match.","solutions":["Upgrade Iceberg to a version whose parser supports the representation type","Inspect the view metadata JSON to identify the unknown representation type","Remove or rewrite the unsupported representation if possible","Report/patch the parser if a custom representation type must round-trip"],"exampleFix":"// before\nString json = ViewRepresentationParser.toJson(representation, generator);\n// after\nif (!\"sql\".equalsIgnoreCase(representation.type())) {\n  throw new UnsupportedOperationException(\"Unsupported type: \" + representation.type());\n}\nViewRepresentationParser.toJson(representation, generator);","handlingStrategy":"try-catch","validationCode":"boolean supported = \"sql\".equalsIgnoreCase(representation.type());","typeGuard":"if (!(representation instanceof SQLViewRepresentation)) { throw new UnsupportedOperationException(\"only SQL representations supported\"); }","tryCatchPattern":"try { parser.toJson(rep, gen); } catch (UnsupportedOperationException e) { // upgrade parser or skip unsupported representation }","preventionTips":["Keep the Iceberg version at or above the writer version of the metadata","Inspect view metadata JSON types before round-tripping files across versions","Avoid custom representation types unless the parser is extended"],"tags":["serialization","view","unsupported-type","forward-compatibility"],"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-14T21:17:11.552Z"}