diff --git a/paimon-core/src/main/java/org/apache/paimon/utils/BulkFormatMapping.java b/paimon-core/src/main/java/org/apache/paimon/utils/BulkFormatMapping.java index d5d28ea4519f..831c6ddbcc91 100644 --- a/paimon-core/src/main/java/org/apache/paimon/utils/BulkFormatMapping.java +++ b/paimon-core/src/main/java/org/apache/paimon/utils/BulkFormatMapping.java @@ -207,8 +207,8 @@ static Pair trimKeyFields( if (positionMap.containsKey(id)) { map[i] = positionMap.get(id); } else { - trimmedFields.add(keyField ? f : field); - map[i] = positionMap.computeIfAbsent(id, k -> index.getAndIncrement()); + map[i] = positionMap.put(id, trimmedFields.size()); + trimmedFields.add(f); } } else { throw new RuntimeException("Can't find field with id: " + id + " in fields.");