{"record":{"id":"33453711ff897068","repo":"apache/iceberg","slug":"not-implemented-for-variant","errorCode":null,"errorMessage":"Not implemented for variant","messagePattern":"Not implemented for variant","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/parquet/TypeWithSchemaVisitor.java","lineNumber":242,"sourceCode":"\n  public T message(Types.StructType iStruct, MessageType message, List<T> fields) {\n    return null;\n  }\n\n  public T struct(Types.StructType iStruct, GroupType struct, List<T> fields) {\n    return null;\n  }\n\n  public T list(Types.ListType iList, GroupType array, T element) {\n    return null;\n  }\n\n  public T map(Types.MapType iMap, GroupType map, T key, T value) {\n    return null;\n  }\n\n  public T variant(Types.VariantType iVariant, GroupType variant, T result) {\n    throw new UnsupportedOperationException(\"Not implemented for variant\");\n  }\n\n  public T primitive(\n      org.apache.iceberg.types.Type.PrimitiveType iPrimitive, PrimitiveType primitive) {\n    return null;\n  }\n\n  public ParquetVariantVisitor<T> variantVisitor() {\n    return null;\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);","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/parquet/TypeWithSchemaVisitor.java#L224-L260","documentation":"TypeWithSchemaVisitor is the base visitor used when traversing a Parquet schema alongside an Iceberg type; each method has a default null-returning or throwing body. The variant() method's default throws UnsupportedOperationException, so any traversal that encounters a Parquet variant group without a visitor override fails.","triggerScenarios":"Calling TypeWithSchemaVisitor.visitVariant (or a schema visit that encounters a variant-typed group) with a visitor subclass that does not override variant().","commonSituations":"Reading/writing tables containing Variant columns with a custom visitor (e.g. a type-to-Type converter, projection pruner) that predates Variant support; copying visitor code from older Iceberg versions.","solutions":["Override variant(Types.VariantType, GroupType, T) in your TypeWithSchemaVisitor subclass with the appropriate handling.","Use a built-in visitor from the same Iceberg version that already supports Variant.","Upgrade iceberg-parquet so the pipeline's visitors handle variant columns."],"exampleFix":"// before\nclass MyVisitor<T> extends TypeWithSchemaVisitor<T> { /* no variant() override */ }\n// after\nclass MyVisitor<T> extends TypeWithSchemaVisitor<T> {\n  @Override\n  public T variant(Types.VariantType iVariant, GroupType variant, T result) {\n    return visitGroup(variant); // handle variant fields\n  }\n}","handlingStrategy":"try-catch","validationCode":"boolean visitorSupportsVariant(TypeWithSchemaVisitor<?> v) {\n  try {\n    java.lang.reflect.Method m = v.getClass().getMethod(\"variant\",\n        Types.VariantType.class, GroupType.class, Object.class);\n    return m.getDeclaringClass() != TypeWithSchemaVisitor.class;\n  } catch (NoSuchMethodException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  result = TypeWithSchemaVisitor.visit(schema, parquetSchema, visitor);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"variant\")) {\n    throw new IllegalArgumentException(\"Visitor does not support Variant columns; upgrade or override variant()\", e);\n  }\n  throw e;\n}","preventionTips":["Override variant() in any custom TypeWithSchemaVisitor if your tables may contain Variant columns.","Test schema traversal against a schema containing a Variant field.","Prefer built-in visitors from your Iceberg version over hand-copied older ones."],"tags":["parquet","visitor","variant"],"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"}