{"record":{"id":"120c39c6437dcec4","repo":"apache/iceberg","slug":"unsupported-type-variant-120c39","errorCode":null,"errorMessage":"Unsupported type: variant","messagePattern":"Unsupported type: variant","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/schema/SchemaWithPartnerVisitor.java","lineNumber":167,"sourceCode":"\n  public R struct(Types.StructType struct, P partner, List<R> fieldResults) {\n    return null;\n  }\n\n  public R field(Types.NestedField field, P partner, R fieldResult) {\n    return null;\n  }\n\n  public R list(Types.ListType list, P partner, R elementResult) {\n    return null;\n  }\n\n  public R map(Types.MapType map, P partner, R keyResult, R valueResult) {\n    return null;\n  }\n\n  public R variant(Types.VariantType variant, P partner) {\n    throw new UnsupportedOperationException(\"Unsupported type: variant\");\n  }\n\n  public R primitive(Type.PrimitiveType primitive, P partner) {\n    return null;\n  }\n}\n","sourceCodeStart":149,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/schema/SchemaWithPartnerVisitor.java#L149-L174","documentation":"SchemaWithPartnerVisitor.variant() is a hook that visitors must override to handle VariantType columns; the base class default throws UnsupportedOperationException. It signals that the current visitor was not written with Variant support in mind and encountered a variant column during schema traversal.","triggerScenarios":"Visiting a schema that contains a Types.VariantType field using a visitor that only overrides visitPrimitive/visitMap/etc. and inherits the default variant() implementation.","commonSituations":"Upgrading a table to format version 3 introduces variant columns, but custom visitor-based code (type rewriters, compatibility checkers, engine adapters) predates Variant support.","solutions":["Override variant(Types.VariantType, P) in the visitor to return the appropriate result for variant columns","Skip or filter variant fields before visiting if they are out of scope","Upgrade to a newer Iceberg version where the relevant visitor implementations support Variant"],"exampleFix":"// before\nclass MyVisitor extends SchemaWithPartnerVisitor<Type, Type> { }\n// after\nclass MyVisitor extends SchemaWithPartnerVisitor<Type, Type> {\n  @Override\n  public Type variant(Types.VariantType variant, Type partner) {\n    return Types.VariantType.get();\n  }\n}","handlingStrategy":"validation","validationCode":"if (schema.columns().stream().anyMatch(c -> c.type().typeId() == Type.TypeID.VARIANT)) {\n  throw new IllegalArgumentException(\"Schema contains variant columns\");\n}","typeGuard":"boolean supportsVariant = visitorClass != null && overridesVariant(visitorClass);","tryCatchPattern":"try { SchemaWithPartnerVisitor.visit(schema, partner, visitor); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"variant\")) { /* handle variant columns */ } else throw e; }","preventionTips":["Override variant() in every SchemaWithPartnerVisitor subclass","Check table format version >= 3 before expecting variant support","Pre-scan schemas for VariantType fields when compatibility matters"],"tags":["schema","visitor","variant","unsupported"],"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"}