apache/iceberg · error · IllegalArgumentException

Unsupported type: ${primitive}

Error message

Unsupported type: ${primitive}

What it means

FlinkPlannedAvroReader.primitive() switches on the Avro primitive type; NULL, BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, ENUM are handled, and anything else reaches the default, throwing IllegalArgumentException 'Unsupported type'.

Source

Thrown at flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/data/FlinkPlannedAvroReader.java:192

        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. Compare the file's Avro schema with the expected read schema and align the producer so only supported primitives reach this path.
  2. Upgrade Iceberg so the reader covers the type, or read the data with a compatible reader version.
  3. Rebuild the read schema (FlinkPlannedAvroReader.create) from the actual file schema instead of a stale projection.
  4. Convert the offending field to a supported type in the upstream pipeline.

Example fix

// before: expected INT but the file schema has a nested record for column 'v'
// after: align schemas so 'v' is an int, or rebuild the reader from the actual schema
FlinkPlannedAvroReader.create(readSchema, predicate); // recreated from actual file schema
Defensive patterns

Strategy: validation

Validate before calling

for (Field f : avroSchema.getFields()) {
  Schema.Type t = f.schema().getType();
  if (!EnumSet.of(BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, BYTES, FIXED, ENUM, NULL, UNION).contains(t)) {
    throw new IllegalArgumentException("unsupported avro type: " + t);
  }
}

Try / catch

try {
  reader = FlinkPlannedAvroReader.create(readSchema, predicate);
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Unsupported type:")) {
    readSchema = alignSchemaWithFile(fileSchema); // rebuild from actual schema
  }
}

Prevention

When it happens

Trigger: An Avro schema whose primitive resolves to a type outside the handled set - typically complex/nested types leaking into the primitive path (e.g. RECORD, ARRAY, MAP, UNION) due to a schema-mapping bug, or unusual Avro type variants.

Common situations: Producer schema evolved to a type the reader wasn't built for; schema reconciliation bugs where a projected field is typed differently than planned; reading files with non-standard Avro encodings.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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