{"record":{"id":"62613415ef9f90fc","repo":"apache/iceberg","slug":"not-implemented-for-variant-626134","errorCode":null,"errorMessage":"Not implemented for variant","messagePattern":"Not implemented for variant","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/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.2/spark/src/main/java/org/apache/iceberg/spark/data/ParquetWithSparkSchemaVisitor.java#L218-L249","documentation":"ParquetWithSparkSchemaVisitor.variant is the hook for visiting Spark VariantType columns backed by Parquet groups; the base implementation unconditionally throws UnsupportedOperationException so subclasses must override it. Hitting this means a variant column was visited but the concrete visitor didn't implement variant handling.","triggerScenarios":"A Parquet read path using ParquetWithSparkSchemaVisitor encounters a Spark VariantType field (three-group variant Parquet layout) while the concrete visitor (e.g. a Parquet value-writer/converter) has no variant() override.","commonSituations":"Reading or rewriting tables containing variant-typed columns with a code path that predates variant support (older runtime or a visitor subclass that never implemented it).","solutions":["Upgrade to an Iceberg version where the specific visitor implements variant support.","Exclude variant columns from the operation (e.g. filter them out of the rewrite/read projection).","If you own the visitor subclass, override variant(VariantType, GroupType) to return a proper handler."],"exampleFix":"// before\nnew MyVisitor() { ... } // variant() not overridden\n// after\n@Override\npublic T variant(VariantType sVariant, GroupType variant) {\n  return buildVariantReader(variant); // implement handling\n}","handlingStrategy":"type-guard","validationCode":"boolean hasVariant = table.schema().columns().stream().anyMatch(f -> f.type().typeId() == Types.VariantType.get().typeId());","typeGuard":"if (type instanceof VariantType) { /* ensure the concrete visitor overrides variant() before proceeding */ }","tryCatchPattern":"try { visitor.primitive(schema, primitive); } catch (UnsupportedOperationException e) { if (e.getMessage().equals(\"Not implemented for variant\")) { /* skip/projection-exclude variant columns */ } else throw e; }","preventionTips":["Check schemas for VariantType columns before running readers/rewriters on older runtimes","Upgrade the runtime if tables contain variant columns","Override variant() in custom visitor subclasses"],"tags":["spark","parquet","variant","visitor"],"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"}