apache/iceberg · error · UnsupportedOperationException

Not a supported type: ${type}

Error message

Not a supported type: ${type}

What it means

SparkValueConverter.convert (Iceberg type -> value for Spark) has a switch over the Iceberg type's typeId and a default branch that throws UnsupportedOperationException('Not a supported type: ' + type). The library throws this when asked to convert an Iceberg type it does not handle in this direction — only the listed primitive types (and their passthroughs) are supported.

Source

Thrown at spark/v4.0/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. Upgrade the Iceberg Spark runtime to a version that supports the type shown in the message
  2. Exclude or cast the offending column before reading (schema projection without that column)
  3. If the type should be representable, cast table column to a supported primitive (e.g. string) and rewrite the table
  4. Verify reader and writer use the same Iceberg version to avoid unknown type ids

Example fix

// before
Dataset<Row> df = spark.read().format("iceberg").load("t"); // includes variant col -> throws
// after
Dataset<Row> df = spark.read().format("iceberg").load("t").select("id", "payload"); // project out unsupported column
Defensive patterns

Strategy: validation

Validate before calling

static boolean isSupportedPrimitive(Type t) {
  switch (t.typeId()) {
    case BOOLEAN: case INTEGER: case LONG: case FLOAT: case DOUBLE:
    case DECIMAL: case STRING: case FIXED: case DATE: case TIMESTAMP: return true;
    default: return false;
  }
}

Type guard

if (isSupportedPrimitive(type)) { Object v = SparkValueConverter.convert(type, object); }

Try / catch

try {
  value = SparkValueConverter.convert(type, obj);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().startsWith("Not a supported type")) { /* project out or upgrade runtime */ }
  throw e;
}

Prevention

When it happens

Trigger: Reading Iceberg data into Spark where a column's Iceberg type falls into the switch's default branch (types not among BOOLEAN..FIXED handled above, e.g. variant or a newer primitive type), reaching SparkValueConverter.convert.

Common situations: Tables containing newer Iceberg types (Variant, Unknown) read through an older SparkValueConverter; custom type extensions; version skew between writer and reader Iceberg versions.

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