apache/iceberg · error · IllegalArgumentException

Unsupported type in partition data:

Error message

Unsupported type in partition data: 

What it means

PartitionData.copy() deep-copies partition values by field type; nested types (STRUCT, LIST, MAP) have no copy path here and immediately throw IllegalArgumentException. Partition values must be primitive/types that can be shallow-copied; nested partition fields are rejected.

Source

Thrown at core/src/main/java/org/apache/iceberg/PartitionData.java:211

  @Override
  public int hashCode() {
    int result = partitionType.hashCode();
    return 31 * result + Arrays.hashCode(data);
  }

  public static Object[] copyData(Types.StructType type, Object[] data) {
    List<Types.NestedField> fields = type.fields();
    Object[] copy = new Object[data.length];
    for (int i = 0; i < data.length; i += 1) {
      if (data[i] == null) {
        copy[i] = null;
      } else {
        Types.NestedField field = fields.get(i);
        switch (field.type().typeId()) {
          case STRUCT:
          case LIST:
          case MAP:
            throw new IllegalArgumentException("Unsupported type in partition data: " + type);
          case BINARY:
          case FIXED:
            byte[] buffer = (byte[]) data[i];
            copy[i] = Arrays.copyOf(buffer, buffer.length);
            break;
          case STRING:
            copy[i] = data[i].toString();
            break;
          default:
            // no need to copy the object
            copy[i] = data[i];
        }
      }
    }

    return copy;
  }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Avoid partitioning by struct/list/map columns; partition by primitive columns or valid transforms instead.
  2. If the spec legitimately contains nested types, copy values manually instead of relying on PartitionData.copy().
  3. Audit the PartitionSpec of the table producing this data and confirm field types are primitive.

Example fix

// before
PartitionSpec spec = PartitionSpec.builderFor(schema).add("nested_struct_field").build();
// after
PartitionSpec spec = PartitionSpec.builderFor(schema).add("primitive_column").build();
Defensive patterns

Strategy: validation

Validate before calling

boolean nested = spec.partitionType().fields().stream()
    .anyMatch(f -> f.type().typeId() == Type.TypeID.STRUCT
        || f.type().typeId() == Type.TypeID.LIST
        || f.type().typeId() == Type.TypeID.MAP);
if (nested) throw new IllegalStateException("Spec has nested partition fields; PartitionData.copy() unsupported");

Try / catch

try {
  PartitionData copied = partitionData.copy();
} catch (IllegalArgumentException e) {
  if (!e.getMessage().startsWith("Unsupported type")) throw e;
  // fall back to reusing the original instance read-only
}

Prevention

When it happens

Trigger: Calling copy() on a PartitionData whose PartitionSpec contains a nested partition field (partitioning by a struct, list, or map column, or by a transform producing such a type), then hitting that field during the copy loop.

Common situations: Declaring partition specs over nested columns (unusual but possible via API misuse); library code building partition data from files written with such specs; custom transforms returning nested types.

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