File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed
main/java/org/apache/paimon/operation
test/java/org/apache/paimon/table Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 3232import org .apache .paimon .schema .SchemaManager ;
3333import org .apache .paimon .schema .TableSchema ;
3434import org .apache .paimon .stats .SimpleStats ;
35+ import org .apache .paimon .table .SpecialFields ;
3536import org .apache .paimon .types .DataField ;
3637import org .apache .paimon .types .RowType ;
3738import 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 }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments