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

  1. Read decimal variants through the Decimal-typed accessor (getDecimal/decimalDataValue) instead.
  2. Align the Flink field type with the actual variant physical type.
  3. 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

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


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_PRECISION

View on GitHub (pinned to 86d9c8fc54)