apache/iceberg · error · UnsupportedOperationException
errMsg(variant, "double")
Error message
errMsg(variant, "double")
What it means
doubleValue converts a Variant to a Flink double but supports only FLOAT and DOUBLE variant types. Other types throw UnsupportedOperationException with errMsg(variant, "double"). This is a guard against reading non-float variants (integers, decimals, strings) via getDouble.
Solutions
- Read decimal variants through the Decimal-typed accessor (getDecimal/decimalDataValue) instead.
- Align the Flink field type with the actual variant physical type.
- Pre-convert the variant value to a float/double if narrowing is intended.
Example fix
// before double d = wrapper.getDouble(pos); // variant is DECIMAL // after BigDecimal bd = variant.getDecimal(); double d = bd.doubleValue();
Defensive patterns
Strategy: type-guard
Validate before calling
if (variant.getType() == Variant.Type.FLOAT || variant.getType() == Variant.Type.DOUBLE) { /* safe to getDouble */ } Type guard
boolean isDoubleVariant(Variant v) { return v.getType() == Variant.Type.FLOAT || v.getType() == Variant.Type.DOUBLE; } Try / catch
try { double d = wrapper.getDouble(pos); } catch (UnsupportedOperationException e) { /* handle decimal/string variants separately */ } Prevention
- Use the decimal accessor for DECIMAL variants, not getDouble.
- Ensure writers emit float/double variants for DOUBLE-typed fields.
- Cover decimal-to-double expectations in tests explicitly.
When it happens
Trigger: Calling getDouble(pos) or elementValue where the Variant's getType() is not FLOAT or DOUBLE — e.g. an INT or DECIMAL variant read through a DOUBLE Flink field.
Common situations: Variant column written as DECIMAL but read as DOUBLE; mixed-type variant data; incorrect Flink schema declaration for a variant field.
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
- errMsg(variant, "int")
- errMsg(variant, "long")
- errMsg(variant, "timestamp")
- Failed to read Variant
- Failed to read Variant
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/a7e13a4aa339758c.
Report an issue: GitHub.
Appendix: source
Thrown at flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/data/VariantRowDataWrapper.java:273
default -> throw new UnsupportedOperationException(errMsg(variant, "int"));
};
}
private static long longValue(Variant variant) {
return switch (variant.getType()) {
case TINYINT -> variant.getByte();
case SMALLINT -> variant.getShort();
case INT -> variant.getInt();
case BIGINT -> variant.getLong();
default -> throw new UnsupportedOperationException(errMsg(variant, "long"));
};
}
private static double doubleValue(Variant variant) {
return switch (variant.getType()) {
case FLOAT -> variant.getFloat();
case DOUBLE -> variant.getDouble();
default -> throw new UnsupportedOperationException(errMsg(variant, "double"));
};
}
private static DecimalData decimalDataValue(Variant variant, DecimalType decimalType) {
return DecimalData.fromBigDecimal(
variant.getDecimal(), decimalType.getPrecision(), decimalType.getScale());
}
private static TimestampData timestampValue(Variant variant, int precision) {
return switch (variant.getType()) {
case TIMESTAMP -> TimestampData.fromLocalDateTime(variant.getDateTime());
case TIMESTAMP_LTZ -> TimestampData.fromInstant(variant.getInstant());
case BIGINT -> {
Preconditions.checkArgument(
precision >= MICROSECOND_PRECISION && precision <= NANOSECOND_PRECISION,
"Invalid precision: %s. Only micros and nanos precision are supported.",
precision);
yield precision > MICROSECOND_PRECISIONView on GitHub (pinned to 86d9c8fc54)