{"record":{"id":"4827c4f6746c4f6d","repo":"apache/iceberg","slug":"field-d-has-unsupported-field-type-s-4827c4","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.2/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.2/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/SortKeySerializer.java#L179-L215","documentation":"SortKeySerializer.serialize() flattens each SortKey field into the DataOutputView by switching on the Iceberg type id. Numeric/text/temporal/primitive types are supported, but STRUCT, MAP, LIST (and the default arm) are not — the SortKey representation is a flattened struct without nested collections, so serialize throws UnsupportedOperationException identifying the field id and type. The table's sort order contains a column with a nested/complex type.","triggerScenarios":"Configuring a table sort order that includes a struct, map, or list column, then running a sorted write (write.distribution.mode=range or sorted write) in Flink so SortKey values must be serialized for the shuffle or sketch.","commonSituations":"Defining ALTER TABLE ... ORDER BY on a column of type map/list/struct by mistake; sort order inherited from Spark where nested sort keys behave differently; schema evolution adding a nested column into the sort spec.","solutions":["Rewrite the table sort order to use only primitive-typed columns (no struct/map/list).","Sort on a primitive component of the nested field (e.g. a top-level string/long extracted by the upstream job) instead of the nested column.","Change write.distribution.mode to 'hash' (on a primitive key) or 'none' to avoid serializing SortKeys.","Check the schema with a tool like DESCRIBE TABLE and confirm each sort column's type before enabling sorted writes."],"exampleFix":"// before\nALTER TABLE t WRITE ORDERED BY tags;  -- tags is list<string>\n// after\nALTER TABLE t WRITE ORDERED BY user_id, created_at;","handlingStrategy":"validation","validationCode":"table.sortOrder().fields().forEach(f -> {\n  Type t = schema.findType(f.sourceId());\n  Preconditions.checkArgument(t.isPrimitiveType(),\n      \"Sort column %s must be primitive, found %s\", f.sourceId(), t);\n});","typeGuard":"boolean sortKeySafe(Type t) {\n  return t.isPrimitiveType();\n}","tryCatchPattern":"try {\n  serializer.serialize(sortKey, view);\n} catch (UnsupportedOperationException e) {\n  LOG.error(\"Sort order uses unsupported nested column; fix table sort order\", e);\n  throw e;\n}","preventionTips":["Inspect the table sort order and schema before enabling sorted writes in Flink.","Never include struct/map/list columns in WRITE ORDERED BY.","Re-check sort order after schema evolution."],"tags":["flink","sort-key","unsupported-type","schema"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}