apache/iceberg · error · UnsupportedOperationException
Variant is not supported
Error message
Variant is not supported
What it means
OrcSchemaWithTypeVisitor's variant() callback handles ORC variant nodes paired with an Iceberg Types.VariantType; the base-class default throws UnsupportedOperationException. Any concrete visitor that does not override it will throw when the schema walk reaches a variant type.
Source
Thrown at orc/src/main/java/org/apache/iceberg/orc/OrcSchemaWithTypeVisitor.java:114
return visitor.variant(iVariant, variant, metadataResult, valueResult);
}
public T record(
Types.StructType iStruct, TypeDescription record, List<String> names, List<T> fields) {
return null;
}
public T list(Types.ListType iList, TypeDescription array, T element) {
return null;
}
public T map(Types.MapType iMap, TypeDescription map, T key, T value) {
return null;
}
public T variant(Types.VariantType iVariant, TypeDescription variant, T metadata, T value) {
throw new UnsupportedOperationException("Variant is not supported");
}
public T primitive(Type.PrimitiveType iPrimitive, TypeDescription primitive) {
return null;
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Upgrade iceberg-orc to a release with variant support so built-in visitors override variant().
- Override variant() in your custom OrcSchemaWithTypeVisitor to return a handled value.
- Use Parquet/Avro for tables containing variant columns.
- Drop variant columns from ORC-backed tables before running schema operations.
Example fix
// after: override in visitor subclass
@Override
public T variant(Types.VariantType iVariant, TypeDescription variant, T metadata, T value) {
return value; // propagate handled child result
} Defensive patterns
Strategy: try-catch
Validate before calling
// detect variant columns in the ORC schema before visiting boolean hasVariant = streamChildren(schema).anyMatch(t -> t.getCategory() == TypeDescription.Category.STRUCT && isVariantStruct(t));
Try / catch
try { OrcSchemaWithTypeVisitor.visit(iType, schema, visitor); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("Variant is not supported")) { degradeGracefully(); } else throw e; } Prevention
- Override variant() in every custom OrcSchemaWithTypeVisitor subclass
- Check table schema for VariantType before choosing ORC as the file format
- Upgrade iceberg-orc when adopting variant columns
When it happens
Trigger: OrcSchemaWithTypeVisitor.visit dispatches to visitVariant → visitor.variant() on a schema containing an ORC variant, and the visitor subclass has not overridden variant().
Common situations: Schema conversion or read/write planning over Iceberg tables with VariantType stored as ORC; custom visitors built on older Iceberg versions that predate variant support.
Related errors
- Variant is not supported
- Unsupported type: variant
- Unsupported type: variant
- Unsupported type: variant
- Cannot handle
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/1850688dd3f086a0.
Report an issue: GitHub.