apache/iceberg · error · UnsupportedOperationException

Unsupported primitive type:

Error message

Unsupported primitive type: 

What it means

SerializedPrimitive.requiredBytes (via payloadSize) computes the payload length for a decoded primitive. If the primitive's physical type has no size rule implemented in this reader, this UnsupportedOperationException is thrown — the serialized variant contains a primitive type this code cannot size.

Source

Thrown at api/src/main/java/org/apache/iceberg/variants/SerializedPrimitive.java:104

      case DECIMAL8:
        return 9;
      case DECIMAL16:
        return 17;
      case UUID:
        return 16;
      case BINARY:
      case STRING:
        Preconditions.checkArgument(
            PRIMITIVE_OFFSET + 4 <= value.remaining(),
            "Invalid variant primitive: %s size field extends past buffer",
            type);
        int size = ByteBuffers.readLittleEndianInt32(value, PRIMITIVE_OFFSET);
        Preconditions.checkArgument(
            size >= 0, "Invalid variant primitive: negative %s size %s", type, size);
        return 4L + size;
    }

    throw new UnsupportedOperationException("Unsupported primitive type: " + type);
  }

  private Object read() {
    switch (type) {
      case NULL:
        return null;
      case BOOLEAN_TRUE:
        return true;
      case BOOLEAN_FALSE:
        return false;
      case INT8:
        return ByteBuffers.readLittleEndianInt8(value, PRIMITIVE_OFFSET);
      case INT16:
        return ByteBuffers.readLittleEndianInt16(value, PRIMITIVE_OFFSET);
      case INT32:
      case DATE:
        return ByteBuffers.readLittleEndianInt32(value, PRIMITIVE_OFFSET);
      case INT64:

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Upgrade the Iceberg version so the type is supported in payloadSize
  2. Validate the variant's primitive type codes before deserialization
  3. Re-write the data with a writer version compatible with the reader
Defensive patterns

Strategy: try-catch

Type guard

boolean supported = java.util.EnumSet.allOf(PhysicalType.class).contains(p.type());

Try / catch

try {
  long size = primitive.requiredBytes();
} catch (UnsupportedOperationException e) {
  // unsupported primitive type; skip or upgrade reader
}

Prevention

When it happens

Trigger: Calling get()/requiredBytes() on a SerializedPrimitive whose PhysicalType falls through the payloadSize switch (an unsupported/unknown primitive type), typically from malformed or newer-spec variant data.

Common situations: Reading variants produced by a newer library version with additional primitive types; corrupted binary variant values; manually constructed buffers with invalid type headers.

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