Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouxxyy committed Nov 7, 2024
1 parent 783afb8 commit e89d1b5
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.table.source.DataSplit;
import org.apache.paimon.table.source.DeletionFile;
import org.apache.paimon.types.DataField;
import org.apache.paimon.types.RowType;
import org.apache.paimon.utils.ProjectedRow;
import org.apache.paimon.utils.Projection;
Expand Down Expand Up @@ -131,11 +132,9 @@ public MergeFileSplitRead withReadKeyType(RowType readKeyType) {
@Override
public MergeFileSplitRead withReadType(RowType readType) {
// todo: replace projectedFields with readType
RowType tableRowType = tableSchema.logicalRowType();
int[][] projectedFields =
Arrays.stream(
tableSchema
.logicalRowType()
.getFieldIndices(readType.getFieldNames()))
Arrays.stream(tableRowType.getFieldIndices(readType.getFieldNames()))
.mapToObj(i -> new int[] {i})
.toArray(int[][]::new);
int[][] newProjectedFields = projectedFields;
Expand All @@ -161,9 +160,16 @@ public MergeFileSplitRead withReadType(RowType readType) {
this.pushdownProjection = projection.pushdownProjection;
this.outerProjection = projection.outerProjection;
if (pushdownProjection != null) {
RowType pushdownRowType =
readType.project(
Arrays.stream(pushdownProjection).mapToInt(arr -> arr[0]).toArray());
List<DataField> fields = tableRowType.getFields();
List<String> 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);
readerFactoryBuilder.withReadValueType(pushdownRowType);
mergeSorter.setProjectedValueType(pushdownRowType);
}
Expand Down

0 comments on commit e89d1b5

Please sign in to comment.