apache/iceberg · error · UnsupportedOperationException
Variant column only supports getVariant()
Error message
Variant column only supports getVariant()
What it means
VariantColumnVector models a Spark VARIANT column as two child vectors (value at ordinal 0, metadata at ordinal 1). getBoolean() has no meaningful mapping to that pair, so it throws UnsupportedOperationException — only getVariant()/getChild are supported for variant columns.
Solutions
- Read the value with getVariant(rowId) instead
- Cast the variant explicitly via variant functions in Spark rather than in the column vector
- Add a VariantType guard in code that iterates batch columns
Example fix
// before boolean b = columnVector.getBoolean(rowId); // after Object variant = columnVector.getVariant(rowId);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(dataType instanceof org.apache.spark.sql.types.VariantType)) { return columnVector.getBoolean(rowId); } Type guard
boolean canGetBoolean(ColumnVector cv, org.apache.spark.sql.types.DataType t) { return !(t instanceof org.apache.spark.sql.types.VariantType); } Try / catch
try { b = cv.getBoolean(rowId); } catch (UnsupportedOperationException e) { if (e.getMessage() != null && e.getMessage().contains("only supports getVariant")) { b = extractBoolean(cv.getVariant(rowId)); } else { throw e; } } Prevention
- Check the batch schema per column before calling typed accessors
- Use variant functions for scalar extraction instead of casting columns
- Avoid generic readers that assume all vectors are primitive-typed
When it happens
Trigger: Calling getBoolean(rowId) on a variant-typed column in a ColumnarBatch produced by Iceberg's vectorized reader; commonly from generic per-row extraction code or an engine that resolved a variant-to-boolean cast to the raw column vector.
Common situations: Custom code reading all columns of a batch by primitive accessors; queries forcing variant-to-boolean casts; compatibility shims porting Iceberg batches into engines that expect plain typed vectors.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Variant column only supports getVariant()
- Variant column only supports getVariant()
- Cannot add column since setting default values in Spark is…
- Cannot convert unknown expression
- Deleted rows scan task is not supported yet
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/e08b07c9aa005a22.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/VariantColumnVector.java:80
return valueChild.isNullAt(rowId);
}
// getChild is what getVariant() calls: child(0) = value, child(1) = metadata
@Override
public ColumnVector getChild(int ordinal) {
if (ordinal == 0) {
return valueChild;
} else if (ordinal == 1) {
return metadataChild;
}
throw new IllegalArgumentException(
"Variant column has only 2 children, got ordinal: " + ordinal);
}
@Override
public boolean getBoolean(int rowId) {
throw unsupported();
}
@Override
public byte getByte(int rowId) {
throw unsupported();
}
@Override
public short getShort(int rowId) {
throw unsupported();
}
@Override
public int getInt(int rowId) {
throw unsupported();
}
@OverrideView on GitHub (pinned to 86d9c8fc54)