apache/iceberg · error · IllegalArgumentException

Unsupported type:

Error message

Unsupported type: 

What it means

SparkAvroWriter.primitive converts Avro primitive types into Iceberg value writers. The switch covers all standard Avro primitives (BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, etc.); the default branch should be unreachable but fires if an unexpected/unrecognized primitive appears. This IllegalArgumentException signals an Avro primitive the writer does not handle.

Source

Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java:166

            return ValueWriters.tinyints();
          } else if (type instanceof ShortType) {
            return ValueWriters.shorts();
          }
          return ValueWriters.ints();
        case LONG:
          return ValueWriters.longs();
        case FLOAT:
          return ValueWriters.floats();
        case DOUBLE:
          return ValueWriters.doubles();
        case STRING:
          return SparkValueWriters.strings();
        case FIXED:
          return ValueWriters.fixed(primitive.getFixedSize());
        case BYTES:
          return ValueWriters.bytes();
        default:
          throw new IllegalArgumentException("Unsupported type: " + primitive);
      }
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the Avro schema and replace unsupported primitives with standard ones.
  2. Align Avro library versions between your app and Iceberg's dependency set.
  3. Upgrade Iceberg to get a writer covering the primitive.
  4. Pre-convert the data to a supported primitive type before writing.
Defensive patterns

Strategy: validation

Validate before calling

// Validate all Avro primitives are standard before writing
Set<org.apache.avro.Schema.Type> standard = EnumSet.of(
    org.apache.avro.Schema.Type.BOOLEAN, org.apache.avro.Schema.Type.INT,
    org.apache.avro.Schema.Type.LONG, org.apache.avro.Schema.Type.FLOAT,
    org.apache.avro.Schema.Type.DOUBLE, org.apache.avro.Schema.Type.STRING,
    org.apache.avro.Schema.Type.FIXED, org.apache.avro.Schema.Type.BYTES,
    org.apache.avro.Schema.Type.NULL);
// walk the schema and assert every leaf type is in `standard`

Type guard

static boolean isStandardPrimitive(org.apache.avro.Schema s) {
  return standard.contains(s.getType());
}

Prevention

When it happens

Trigger: Writing data whose Avro schema contains a primitive type not covered by the writer's switch (e.g. NULL-type fields surfacing in unusual positions, or corrupted/foreign schema objects passed as Avro primitives).

Common situations: Rare in practice: encountered with hand-built or dynamically generated Avro schemas, or when Iceberg's writer is version-mismatched with an Avro library emitting new primitive kinds.

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