apache/iceberg · error · IllegalArgumentException

Unsupported type:

Error message

Unsupported type: 

What it means

DataWriter's primitive() method converts an Iceberg primitive type into an Avro ValueWriter. When it encounters a primitive type it has no writer case for (e.g. a type outside its supported switch of int/long/float/double/string/fixed/bytes etc.), it throws this IllegalArgumentException. It signals the write schema contains a primitive the Avro data writer cannot serialize.

Source

Thrown at core/src/main/java/org/apache/iceberg/data/avro/DataWriter.java:165

          return ValueWriters.nulls();
        case BOOLEAN:
          return ValueWriters.booleans();
        case INT:
          return ValueWriters.ints();
        case LONG:
          return ValueWriters.longs();
        case FLOAT:
          return ValueWriters.floats();
        case DOUBLE:
          return ValueWriters.doubles();
        case STRING:
          return ValueWriters.strings();
        case FIXED:
          return ValueWriters.fixed(primitive.getFixedSize());
        case BYTES:
          return ValueWriters.byteBuffers();
        default:
          throw new IllegalArgumentException("Unsupported type: " + primitive);
      }
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the schema and identify which primitive type lacks a case in DataWriter.primitive(), then exclude or convert that column.
  2. Upgrade Iceberg to a version whose DataWriter supports the type.
  3. Convert unsupported primitives (e.g. to string or bytes) in a projected schema before writing.
  4. If the type genuinely should be supported, implement a case in the switch with an appropriate ValueWriter.

Example fix

// before
Schema schema = new Schema(Types.NestedField.required(1, "ts", Types.TimestampType.withZone()));
avroWriter.write(schema, record); // throws for unsupported primitive
// after
Schema projected = schema.select("id", "name"); // only supported primitives
avroWriter.write(projected, record);
Defensive patterns

Strategy: validation

Validate before calling

boolean allSupported(Schema schema) {
  for (Types.NestedField f : schema.columns()) {
    if (f.type().isPrimitiveType() &&
        !Set.of("int","long","float","double","boolean","date","string","fixed","bytes","time","timestamp","decimal","uuid").contains(f.type().toString())) {
      return false;
    }
  }
  return true;
}
if (!allSupported(schema)) throw new IllegalArgumentException("Schema has primitives unsupported by Avro writer");

Type guard

if (type.isPrimitiveType() && !SUPPORTED.contains(type.typeId())) { skip or convert }

Try / catch

try { writer.write(schema, record); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported type")) { /* project/convert schema and retry */ } else throw e; }

Prevention

When it happens

Trigger: Calling GenericAvroWriter/DataWriter.write on data whose schema contains a primitive type not handled by the switch (e.g. certain logical/date-time primitives depending on version), typically reached via write(Schema, T) on a file writer built with this DataWriter.

Common situations: Writing tables with newer Iceberg types using an older writer path; custom or unknown primitives; type evolution adding a type the Avro writer path doesn't support; mapping a schema programmatically with a typo'd or exotic type.

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