{"record":{"id":"4e79026f063eb879","repo":"apache/iceberg","slug":"not-implemented-for-variant-4e7902","errorCode":null,"errorMessage":"Not implemented for variant","messagePattern":"Not implemented for variant","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/ParquetWithSparkSchemaVisitor.java","lineNumber":236,"sourceCode":"\n  public T struct(StructType sStruct, GroupType struct, List<T> fields) {\n    return null;\n  }\n\n  public T list(ArrayType sArray, GroupType array, T element) {\n    return null;\n  }\n\n  public T map(MapType sMap, GroupType map, T key, T value) {\n    return null;\n  }\n\n  public T primitive(DataType sPrimitive, PrimitiveType primitive) {\n    return null;\n  }\n\n  public T variant(VariantType sVariant, GroupType variant) {\n    throw new UnsupportedOperationException(\"Not implemented for variant\");\n  }\n\n  protected String[] currentPath() {\n    return Lists.newArrayList(fieldNames.descendingIterator()).toArray(new String[0]);\n  }\n\n  protected String[] path(String name) {\n    List<String> list = Lists.newArrayList(fieldNames.descendingIterator());\n    list.add(name);\n    return list.toArray(new String[0]);\n  }\n}\n","sourceCodeStart":218,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/ParquetWithSparkSchemaVisitor.java#L218-L249","documentation":"ParquetWithSparkSchemaVisitor.variant is the hook for visiting Spark Variant columns in Parquet schemas, and the base implementation throws UnsupportedOperationException because variant handling is not implemented in the visitor. Subclasses are expected to override it; hitting this means the read path encountered a variant column without an override.","triggerScenarios":"Reading/walking a Parquet file whose Spark schema contains a VariantType column using ParquetWithSparkSchemaVisitor (or a subclass that doesn't override variant).","commonSituations":"Reading tables written with Iceberg variant type (spec v3) using a Spark read path whose visitor hasn't implemented variant support; custom visitor subclasses extending the base without implementing variant.","solutions":["Upgrade to an Iceberg version whose Parquet reader supports variant columns","Exclude the variant column from the read projection (select other columns only)","Override variant() in your custom visitor subclass with a real implementation","Rewrite the column to a supported type if variant support is unavailable in your runtime"],"exampleFix":"// before: custom visitor without variant override\nnew MyVisitor() { ... } // inherits throwing variant()\n// after\n@Override\npublic T variant(VariantType sVariant, GroupType variant) {\n  return visitVariant(variant); // real implementation\n}","handlingStrategy":"try-catch","validationCode":"boolean hasVariant = table.schema().columns().stream()\n    .anyMatch(c -> c.type().typeId() == Type.TypeID.VARIANT);\nif (hasVariant) { /* ensure runtime supports variant or exclude the column */ }","typeGuard":"if (schema instanceof VariantType) { /* route to variant-aware visitor */ }","tryCatchPattern":"try { ParquetWithSparkSchemaVisitor.visit(schema, type, visitor); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"variant\")) { /* exclude column or upgrade */ } else { throw e; } }","preventionTips":["Upgrade Iceberg before reading tables with variant columns","Override variant() when subclassing ParquetWithSparkSchemaVisitor","Exclude variant columns from projections if the runtime lacks support"],"tags":["spark","parquet","variant","visitor","not-implemented"],"backgroundTag":"method-not-implemented","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"}