{"record":{"id":"17327d4fed06ab32","repo":"apache/flink","slug":"fieldindex-mismatch-name","errorCode":null,"errorMessage":"FieldIndex mismatch name={}: {} != {}","messagePattern":"FieldIndex mismatch name=(.+?): (.+?) != (.+?)","errorType":"validation","errorClass":"IncompatibleSchemaModificationException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/protobuf/PatchedProtoWriteSupport.java","lineNumber":620,"sourceCode":"    }\n\n    /** validates mapping between protobuffer fields and parquet fields. */\n    private void validatedMapping(Descriptor descriptor, GroupType parquetSchema) {\n        List<FieldDescriptor> allFields = descriptor.getFields();\n\n        for (FieldDescriptor fieldDescriptor : allFields) {\n            String fieldName = fieldDescriptor.getName();\n            int fieldIndex = fieldDescriptor.getIndex();\n            int parquetIndex = parquetSchema.getFieldIndex(fieldName);\n            if (fieldIndex != parquetIndex) {\n                String message =\n                        \"FieldIndex mismatch name=\"\n                                + fieldName\n                                + \": \"\n                                + fieldIndex\n                                + \" != \"\n                                + parquetIndex;\n                throw new IncompatibleSchemaModificationException(message);\n            }\n        }\n    }\n\n    class StringWriter extends FieldWriter {\n        @Override\n        final void writeRawValue(Object value) {\n            Binary binaryString = Binary.fromString((String) value);\n            recordConsumer.addBinary(binaryString);\n        }\n    }\n\n    class IntWriter extends FieldWriter {\n        @Override\n        final void writeRawValue(Object value) {\n            recordConsumer.addInteger((Integer) value);\n        }\n    }","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/protobuf/PatchedProtoWriteSupport.java#L602-L638","documentation":"validatedMapping checks that each protobuf field's declaration index equals its position (field index) in the converted parquet schema. A mismatch means the parquet schema field order does not line up with the descriptor order, which would silently write values to wrong columns; it therefore throws IncompatibleSchemaModificationException.","triggerScenarios":"A parquet schema derived from the descriptor whose fields are reordered, renamed (breaking getFieldIndex lookup), or filtered relative to the protobuf descriptor - e.g. custom schema conversion, case-mismatched names, or a descriptor/parquet-schema version skew.","commonSituations":"Evolving a .proto between writer versions while reusing a stored/derived parquet schema; renaming fields (parquet getFieldIndex is case-sensitive); schema pruning applied to the map type.","solutions":["Regenerate the parquet schema from the current protobuf descriptor so ordering matches","Avoid renaming or reordering proto fields that back parquet columns; add new fields only at the end","Keep field names identical (case included) between proto and parquet schema"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for (FieldDescriptor fd : descriptor.getFields()) {\n  if (parquetSchema.getFieldIndex(fd.getName()) != fd.getIndex()) { throw new IllegalStateException(\"field order mismatch: \" + fd.getFullName()); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always derive the parquet schema from the same descriptor version as the messages","Never rename/reorder proto fields that map to parquet columns","Treat this exception as a hard schema-skew failure: regenerate schema, do not patch data"],"tags":["parquet","protobuf","schema-evolution","field-order"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}