diff --git a/paimon-core/src/main/java/org/apache/paimon/operation/MergeFileSplitRead.java b/paimon-core/src/main/java/org/apache/paimon/operation/MergeFileSplitRead.java index 5f2648e62a65..23a3a576e4a6 100644 --- a/paimon-core/src/main/java/org/apache/paimon/operation/MergeFileSplitRead.java +++ b/paimon-core/src/main/java/org/apache/paimon/operation/MergeFileSplitRead.java @@ -160,16 +160,18 @@ public MergeFileSplitRead withReadType(RowType readType) { this.pushdownProjection = projection.pushdownProjection; this.outerProjection = projection.outerProjection; if (pushdownProjection != null) { - List fields = tableRowType.getFields(); - List projectedFieldNames = - Arrays.stream( - Arrays.stream(pushdownProjection) - .mapToInt(arr -> arr[0]) - .toArray()) - .mapToObj(fields::get) - .map(DataField::name) - .collect(Collectors.toList()); - RowType pushdownRowType = readType.project(projectedFieldNames); + List tableFields = tableRowType.getFields(); + List readFields = readType.getFields(); + List finalReadFields = new ArrayList<>(); + for (int i : Arrays.stream(pushdownProjection).mapToInt(arr -> arr[0]).toArray()) { + DataField requiredField = tableFields.get(i); + finalReadFields.add( + readFields.stream() + .filter(x -> x.name().equals(requiredField.name())) + .findFirst() + .orElse(requiredField)); + } + RowType pushdownRowType = new RowType(finalReadFields); readerFactoryBuilder.withReadValueType(pushdownRowType); mergeSorter.setProjectedValueType(pushdownRowType); }