{"record":{"id":"168b46d787098b54","repo":"apache/iceberg","slug":"unsupported-type-in-partition-data","errorCode":null,"errorMessage":"Unsupported type in partition data: ","messagePattern":"Unsupported type in partition data: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/PartitionData.java","lineNumber":211,"sourceCode":"  @Override\n  public int hashCode() {\n    int result = partitionType.hashCode();\n    return 31 * result + Arrays.hashCode(data);\n  }\n\n  public static Object[] copyData(Types.StructType type, Object[] data) {\n    List<Types.NestedField> fields = type.fields();\n    Object[] copy = new Object[data.length];\n    for (int i = 0; i < data.length; i += 1) {\n      if (data[i] == null) {\n        copy[i] = null;\n      } else {\n        Types.NestedField field = fields.get(i);\n        switch (field.type().typeId()) {\n          case STRUCT:\n          case LIST:\n          case MAP:\n            throw new IllegalArgumentException(\"Unsupported type in partition data: \" + type);\n          case BINARY:\n          case FIXED:\n            byte[] buffer = (byte[]) data[i];\n            copy[i] = Arrays.copyOf(buffer, buffer.length);\n            break;\n          case STRING:\n            copy[i] = data[i].toString();\n            break;\n          default:\n            // no need to copy the object\n            copy[i] = data[i];\n        }\n      }\n    }\n\n    return copy;\n  }\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/PartitionData.java#L193-L229","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Avoid partitioning by struct/list/map columns; partition by primitive columns or valid transforms instead.","If the spec legitimately contains nested types, copy values manually instead of relying on PartitionData.copy().","Audit the PartitionSpec of the table producing this data and confirm field types are primitive."],"exampleFix":"// before\nPartitionSpec spec = PartitionSpec.builderFor(schema).add(\"nested_struct_field\").build();\n// after\nPartitionSpec spec = PartitionSpec.builderFor(schema).add(\"primitive_column\").build();","handlingStrategy":"validation","validationCode":"boolean nested = spec.partitionType().fields().stream()\n    .anyMatch(f -> f.type().typeId() == Type.TypeID.STRUCT\n        || f.type().typeId() == Type.TypeID.LIST\n        || f.type().typeId() == Type.TypeID.MAP);\nif (nested) throw new IllegalStateException(\"Spec has nested partition fields; PartitionData.copy() unsupported\");","typeGuard":null,"tryCatchPattern":"try {\n  PartitionData copied = partitionData.copy();\n} catch (IllegalArgumentException e) {\n  if (!e.getMessage().startsWith(\"Unsupported type\")) throw e;\n  // fall back to reusing the original instance read-only\n}","preventionTips":["Only partition by primitive columns or valid transforms.","Check spec.partitionType() for STRUCT/LIST/MAP fields before any code path calling copy().","Reject such specs at table-creation time in your tooling."],"tags":["unsupported-type","partition-data","nested-types","java"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}