{"record":{"id":"8aa371f420b0c3ad","repo":"apache/flink","slug":"record-deserialization-with-leading-normalized-key-8aa371","errorCode":null,"errorMessage":"Record deserialization with leading normalized keys not supported.","messagePattern":"Record deserialization with leading normalized keys not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RowComparator.java","lineNumber":369,"sourceCode":"            TypeComparator<Object> comparator = comparators[i];\n            Object element = record.getField(keyPositions[i]); // element can be null\n            // write key\n            comparator.putNormalizedKey(element, target, currentOffset, len);\n\n            bytesLeft -= len;\n            currentOffset += len;\n        }\n    }\n\n    @Override\n    public void writeWithKeyNormalization(Row record, DataOutputView target) throws IOException {\n        throw new UnsupportedOperationException(\n                \"Record serialization with leading normalized keys not supported.\");\n    }\n\n    @Override\n    public Row readWithKeyDenormalization(Row reuse, DataInputView source) throws IOException {\n        throw new UnsupportedOperationException(\n                \"Record deserialization with leading normalized keys not supported.\");\n    }\n\n    @Override\n    public boolean invertNormalizedKey() {\n        return invertNormKey;\n    }\n\n    @Override\n    public TypeComparator<Row> duplicate() {\n        NullAwareComparator<?>[] comparatorsCopy = new NullAwareComparator<?>[comparators.length];\n        for (int i = 0; i < comparators.length; i++) {\n            comparatorsCopy[i] = (NullAwareComparator<?>) comparators[i].duplicate();\n        }\n\n        TypeSerializer<?>[] serializersCopy = new TypeSerializer<?>[serializers.length];\n        for (int i = 0; i < serializers.length; i++) {\n            serializersCopy[i] = serializers[i].duplicate();","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RowComparator.java#L351-L387","documentation":"RowComparator.readWithKeyDenormalization() intentionally throws UnsupportedOperationException. It is the inverse of writeWithKeyNormalization(): the framework would call it to strip leading normalized key bytes during deserialization. Since Row does not embed normalized keys into its serialized form, this operation is unsupported by design.","triggerScenarios":"A DataSet operator that wrote key-normalized records attempts to read them back through readWithKeyDenormalization(). For RowComparator this path does not exist, so the call fails immediately.","commonSituations":"Same as error 669: a DataSet pipeline using Row as a keyed type in an operator that expects key-normalized serialization/deserialization symmetry. This typically surfaces as the read-side counterpart of the same unsupported code path.","solutions":["Avoid Row as a keyed type in DataSet operators that require key-normalized serialization; use Tuple or POJO.","Switch to the Table API / SQL which manages Row key comparison internally.","Ensure the operator uses the plain serialize/deserialize path rather than key-normalized variants."],"exampleFix":"// before — Row keyed in an operator that reads with key denormalization\nDataSet<Row> rows = ...;\nrows.groupBy(0).sortGroup(1, Order.ASCENDING); // may trigger readWithKeyDenormalization\n\n// after — use a Tuple key to avoid the unsupported Row key-normalization path\nDataSet<Tuple2<Integer, Row>> keyed =\n    rows.map(r -> Tuple2.of((Integer) r.getField(0), r));\nkeyed.groupBy(0).sortGroup(1, Order.ASCENDING);","handlingStrategy":"fallback","validationCode":"// Same as 669: readWithKeyDenormalization is unsupported for RowComparator.\n// Avoid the code path entirely by not using Row as a key in DataSet\n// operators that require key-normalized serialization.","typeGuard":null,"tryCatchPattern":"// UnsupportedOperationException — no runtime recovery possible.\n// Redesign the pipeline to avoid Row keys in DataSet key-normalized paths.","preventionTips":["Use Tuple or POJO types for keyed DataSet operations.","Route Row-based workloads through the Table API / SQL runtime.","Test keyed DataSet pipelines with Row types early to surface this limitation."],"tags":["row","comparator","unsupported-operation","normalized-key","dataset-api"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}