{"record":{"id":"39b5d4919af40b30","repo":"apache/iceberg","slug":"field-d-has-unsupported-field-type-s-39b5d4","errorCode":null,"errorMessage":"Field %d has unsupported field type: %s","messagePattern":"Field (.+?) has unsupported field type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/SortKeySerializer.java","lineNumber":197,"sourceCode":"        case FIXED:\n        case BINARY:\n          byte[] bytes = record.get(i, ByteBuffer.class).array();\n          target.writeInt(bytes.length);\n          target.write(bytes);\n          break;\n        case DECIMAL:\n          BigDecimal decimal = record.get(i, BigDecimal.class);\n          byte[] decimalBytes = decimal.unscaledValue().toByteArray();\n          target.writeInt(decimalBytes.length);\n          target.write(decimalBytes);\n          target.writeInt(decimal.scale());\n          break;\n        case STRUCT:\n        case MAP:\n        case LIST:\n        default:\n          // SortKey transformation is a flattened struct without list and map\n          throw new UnsupportedOperationException(\n              String.format(\n                  Locale.ROOT, \"Field %d has unsupported field type: %s\", fieldId, typeId));\n      }\n    }\n  }\n\n  @Override\n  public SortKey deserialize(DataInputView source) throws IOException {\n    // copying is a little faster than constructing a new SortKey object\n    SortKey deserialized = lazySortKey().copy();\n    deserialize(deserialized, source);\n    return deserialized;\n  }\n\n  @Override\n  public SortKey deserialize(SortKey reuse, DataInputView source) throws IOException {\n    Preconditions.checkArgument(\n        reuse.size() == size,","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/SortKeySerializer.java#L179-L215","documentation":"SortKeySerializer.serialize() throws UnsupportedOperationException when a SortKey field has a type (STRUCT, MAP, LIST, or an unrecognized typeId) that the flattened sort-key encoding cannot write. Sort keys must consist of primitive-comparable types; nested types cannot be serialized into the shuffle payload.","triggerScenarios":"The sort order used by the key shuffle sink includes a column of type STRUCT, MAP, or LIST, so SortKey construction encounters that typeId during serialization (also triggered via copy() in serializer snapshot handling).","commonSituations":"Configuring a table's sort order on a nested column or array; defining ORDER BY on a struct field and then writing through the key-aware shuffle sink; an unhandled/unknown typeId arriving from a newer schema version.","solutions":["Change the table's sort order to use only primitive columns (e.g., extract a primitive member of the struct as a top-level column).","Flatten nested data: write the desired leaf value into a primitive column and sort on that.","If the typeId is from a newly supported type in a newer Iceberg version, upgrade iceberg-flink-runtime to match the writer's schema handling.","Validate the sort order before starting the job: assert every field of the sort order is a primitive type."],"exampleFix":"// before: sort order on struct field\nSortOrder.builderFor(schema).asc(\"nested_struct\").build();\n// after: sort on a primitive column\nSortOrder.builderFor(schema).asc(\"nested_struct_id\").build();","handlingStrategy":"validation","validationCode":"for (SortField f : sortOrder.fields()) {\n  Type t = schema.findType(f.sourceId());\n  Preconditions.checkArgument(t.isPrimitiveType(),\n      \"Sort field %s must be primitive, found: %s\", f.sourceId(), t);\n}","typeGuard":"boolean isSortKeySerializable(Schema schema, SortOrder order) {\n  return order.fields().stream()\n      .allMatch(f -> schema.findType(f.sourceId()).isPrimitiveType());\n}","tryCatchPattern":"try {\n  sortKeySerializer.serialize(sortKey, out);\n} catch (UnsupportedOperationException e) {\n  LOG.error(\"Sort order contains nested type: {}\", e.getMessage());\n  throw e;\n}","preventionTips":["Define sort orders only on primitive columns","Flatten nested fields into primitive columns before sorting","Validate sort order fields at job submission"],"tags":["flink","sort-key","unsupported-type","serialization"],"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"}