apache/iceberg · error · java.lang.IllegalArgumentException

Unsupported type: ${primitive}

Error message

Unsupported type: ${primitive}

What it means

FlinkPlannedAvroReader.primitive falls through to a default branch that rejects Avro primitive types it cannot map to a Flink value reader (anything beyond NULL/BOOLEAN/INT/LONG/FLOAT/DOUBLE/FIXED/BYTES/ENUM — e.g. STRING/MAP handled elsewhere, but RECORD/UNION reaching here is invalid). This IllegalArgumentException signals an unexpected or unsupported Avro primitive in the reader's visit path.

Source

Thrown at flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/FlinkPlannedAvroReader.java:198

        case LONG:
          return ValueReaders.longs();
        case FLOAT:
          if (partner != null && partner.typeId() == Type.TypeID.DOUBLE) {
            return ValueReaders.floatsAsDoubles();
          }
          return ValueReaders.floats();
        case DOUBLE:
          return ValueReaders.doubles();
        case STRING:
          return FlinkValueReaders.strings();
        case FIXED:
          return ValueReaders.fixed(primitive.getFixedSize());
        case BYTES:
          return ValueReaders.bytes();
        case ENUM:
          return FlinkValueReaders.enums(primitive.getEnumSymbols());
        default:
          throw new IllegalArgumentException("Unsupported type: " + primitive);
      }
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the Avro schema of the file/stream and confirm only supported primitive types are used
  2. Normalize the schema in the producer (avoid exotic/unusual types at this position)
  3. Upgrade Iceberg; if a valid Avro type is rejected, file an issue or extend FlinkPlannedAvroReader

Example fix

// before
Schema bad = Schema.create(Schema.Type.STRING); // routed into primitive() unexpectedly
// after: ensure string fields are handled by the string reader path
Schema ok = Schema.create(Schema.Type.BYTES);
Defensive patterns

Strategy: validation

Validate before calling

Set<Schema.Type> ok = Set.of(Schema.Type.BOOLEAN, Schema.Type.INT, Schema.Type.LONG, Schema.Type.FLOAT, Schema.Type.DOUBLE, Schema.Type.FIXED, Schema.Type.BYTES, Schema.Type.ENUM, Schema.Type.NULL);
if (!ok.contains(primitive.getType())) throw new IllegalArgumentException("Unsupported Avro primitive: " + primitive.getType());

Type guard

boolean isSupportedPrimitive(Schema s) { return Set.of(Schema.Type.BOOLEAN, Schema.Type.INT, Schema.Type.LONG, Schema.Type.FLOAT, Schema.Type.DOUBLE, Schema.Type.FIXED, Schema.Type.BYTES, Schema.Type.ENUM, Schema.Type.NULL).contains(s.getType()); }

Try / catch

try { ... } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported type: ")) { /* inspect primitive, adjust schema */ } else throw e; }

Prevention

When it happens

Trigger: Constructing a Flink value reader for an Avro Schema whose primitive type hits the default branch — e.g. an unexpected primitive enum value or a schema shape that routes an unsupported type into primitive().

Common situations: Malformed or hand-crafted Avro schemas; schema registry returning incompatible schemas; Avro library version introducing new primitive kinds not yet mapped.

Related errors


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