apache/iceberg · error · UnsupportedOperationException

Not a supported type: type

Error message

Not a supported type: type

What it means

SparkValueConverter.convert() converts Iceberg internal values to Spark-compatible values for primitive types. If a type is not handled in the switch (e.g. a nested STRUCT, LIST, or MAP is passed into this primitive-only path), it throws UnsupportedOperationException. This signals that the converter does not support the given Iceberg type for this conversion direction.

Source

Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java:90

        // if spark.sql.datetime.java8API.enabled is set to true, java.time.LocalDate
        // for Spark SQL DATE type otherwise java.sql.Date is returned.
        return DateTimeUtils.anyToDays(object);
      case TIMESTAMP:
        return DateTimeUtils.anyToMicros(object);
      case BINARY:
        return ByteBuffer.wrap((byte[]) object);
      case INTEGER:
        return ((Number) object).intValue();
      case BOOLEAN:
      case LONG:
      case FLOAT:
      case DOUBLE:
      case DECIMAL:
      case STRING:
      case FIXED:
        return object;
      default:
        throw new UnsupportedOperationException("Not a supported type: " + type);
    }
  }

  private static Record convert(Types.StructType struct, Row row) {
    if (row == null) {
      return null;
    }

    Record record = GenericRecord.create(struct);
    List<Types.NestedField> fields = struct.fields();
    for (int i = 0; i < fields.size(); i += 1) {
      Types.NestedField field = fields.get(i);

      Type fieldType = field.type();

      switch (fieldType.typeId()) {
        case STRUCT:
          record.set(i, convert(fieldType.asStructType(), row.getStruct(i)));

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Pre-filter or branch: only call convert() for primitive types; handle StructType/ListType/MapType via convert(struct/row), convert(list), or convert(map) overloads
  2. Add explicit handling or a clearer exception for the specific type you need converted
  3. Check the Iceberg type of the field before conversion with type.typeId() and log/skip unsupported fields

Example fix

// before
Object converted = SparkValueConverter.convert(field.type(), value);
// after
if (field.type().isPrimitiveType()) {
  Object converted = SparkValueConverter.convert(field.type(), value);
} else {
  // route structs/lists/maps to their dedicated convert overloads
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!type.isPrimitiveType()) { throw new IllegalArgumentException("Use nested-type conversion for " + type); }
Object converted = SparkValueConverter.convert(type, value);

Type guard

boolean isConvertiblePrimitive = type != null && type.isPrimitiveType()
    && type.typeId() != Type.TypeID.TIMESTAMP; // match the switch's handled set

Try / catch

try {
  converted = SparkValueConverter.convert(type, value);
} catch (UnsupportedOperationException e) {
  LOG.warn("Skipping unsupported type {}", type, e);
  converted = null;
}

Prevention

When it happens

Trigger: Calling SparkValueConverter.convert(...) with a Type whose typeId() is not BOOLEAN/INTEGER/LONG/FLOAT/DOUBLE/DECIMAL/STRING/FIXED — most commonly a nested or non-primitive type such as StructType, ListType, MapType, or a timestamp/binary variant not matched by any case.

Common situations: Developers use SparkValueConverter directly in custom readers/writers or tests and feed it a schema containing nested or timestamp types; it typically appears when writing generic conversion code that doesn't filter to primitive types first.

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/a1439a4d6df1f0bf. Report an issue: GitHub.