apache/iceberg · error · IllegalArgumentException

Unsupported logical type: {logicalType}

Error message

Unsupported logical type: {logicalType}

What it means

SparkAvroWriter maps Avro schema primitives to Iceberg value writers for writing Avro data. Within a logical type (string logical types like date/time/decimal/uuid), an unrecognized logical type name has no writer mapping, so it throws IllegalArgumentException. This keeps the writer from silently producing wrong encodings for unknown Avro logical types.

Source

Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java:142

      if (logicalType != null) {
        switch (logicalType.getName()) {
          case "date":
            // Spark uses the same representation
            return ValueWriters.ints();

          case "timestamp-micros":
            // Spark uses the same representation
            return ValueWriters.longs();

          case "decimal":
            LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) logicalType;
            return SparkValueWriters.decimal(decimal.getPrecision(), decimal.getScale());

          case "uuid":
            return SparkValueWriters.uuids();

          default:
            throw new IllegalArgumentException("Unsupported logical type: " + logicalType);
        }
      }

      switch (primitive.getType()) {
        case NULL:
          return ValueWriters.nulls();
        case BOOLEAN:
          return ValueWriters.booleans();
        case INT:
          if (type instanceof ByteType) {
            return ValueWriters.tinyints();
          } else if (type instanceof ShortType) {
            return ValueWriters.shorts();
          }
          return ValueWriters.ints();
        case LONG:
          return ValueWriters.longs();
        case FLOAT:

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Remove or remap the unsupported logical type in the Avro schema (use a plain primitive type)
  2. Upgrade Iceberg in case a newer version maps the logical type
  3. Pre-convert the data to a supported type before writing
  4. Register/log an issue to add support for the specific logical type
Defensive patterns

Strategy: validation

Validate before calling

org.apache.avro.Schema field = avroSchema.getField("f").schema();
if (field.getLogicalType() != null && field.getLogicalType().getName().equals("my-custom-type")) {
  throw new IllegalStateException("Unsupported Avro logical type: my-custom-type");
}

Type guard

boolean supportedLogicalType(org.apache.avro.Schema s) {
  LogicalType lt = s.getLogicalType();
  return lt == null || Set.of("date","time-millis","time-micros","timestamp-millis",
      "timestamp-micros","local-timestamp-millis","local-timestamp-micros",
      "decimal","uuid").contains(lt.getName());
}

Try / catch

try {
  writer.write(row);
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Unsupported logical type")) { /* normalize the schema */ }
  else throw e;
}

Prevention

When it happens

Trigger: Writing Avro records whose schema declares a string logical type other than date, time-millis, time-micros, timestamp-millis, timestamp-micros, local-timestamp-*, decimal, or uuid — e.g. a custom or vendor-specific Avro logical type.

Common situations: Reading Avro files produced by third-party tools with custom logical types; newer Avro logical types not yet mapped; schema evolution introducing unknown logical types.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/d40e3b3e57f70a16. Report an issue: GitHub.