Skip to content

Commit 0227894

Browse files
author
喆宇
committed
[core] DataEvolutionFileStoreScan should not filter files by read type when it contains no physical columns.
1 parent 87ee257 commit 0227894

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

paimon-core/src/main/java/org/apache/paimon/operation/DataEvolutionFileStoreScan.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.paimon.schema.SchemaManager;
3333
import org.apache.paimon.schema.TableSchema;
3434
import org.apache.paimon.stats.SimpleStats;
35+
import org.apache.paimon.table.SpecialFields;
3536
import org.apache.paimon.types.DataField;
3637
import org.apache.paimon.types.RowType;
3738
import org.apache.paimon.utils.RangeHelper;
@@ -127,8 +128,14 @@ private boolean filterManifestByRowIds(ManifestFileMeta manifest) {
127128

128129
@Override
129130
public FileStoreScan withReadType(RowType readType) {
130-
if (readType != null && !readType.getFields().isEmpty()) {
131-
this.readType = readType;
131+
if (readType != null) {
132+
List<DataField> nonSystemFields =
133+
readType.getFields().stream()
134+
.filter(f -> !SpecialFields.isSystemField(f.id()))
135+
.collect(Collectors.toList());
136+
if (!nonSystemFields.isEmpty()) {
137+
this.readType = readType;
138+
}
132139
}
133140
return this;
134141
}

paimon-core/src/test/java/org/apache/paimon/table/DataEvolutionTableTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,34 @@ public void testBasic() throws Exception {
109109
assertThat(r.getString(1).toString()).isEqualTo("a");
110110
assertThat(r.getString(2).toString()).isEqualTo("c");
111111
});
112+
113+
// projection with only special fields.
114+
readBuilder = getTableDefault().newReadBuilder();
115+
reader =
116+
readBuilder
117+
.withReadType(RowType.of(SpecialFields.ROW_ID))
118+
.newRead()
119+
.createReader(readBuilder.newScan().plan());
120+
AtomicInteger cnt = new AtomicInteger(0);
121+
reader.forEachRemaining(
122+
r -> {
123+
cnt.incrementAndGet();
124+
});
125+
assertThat(cnt.get()).isEqualTo(1);
126+
127+
// projection with an empty read type
128+
readBuilder = getTableDefault().newReadBuilder();
129+
reader =
130+
readBuilder
131+
.withReadType(RowType.of())
132+
.newRead()
133+
.createReader(readBuilder.newScan().plan());
134+
AtomicInteger cnt1 = new AtomicInteger(0);
135+
reader.forEachRemaining(
136+
r -> {
137+
cnt1.incrementAndGet();
138+
});
139+
assertThat(cnt1.get()).isEqualTo(1);
112140
}
113141

114142
@Test

0 commit comments

Comments
 (0)