@@ -134,6 +134,45 @@ public void testPartitionSourceRename() throws IOException {
134134 assertThat (tasks ).hasSize (1 );
135135 }
136136
137+ @ TestTemplate
138+ public void testPartitionSourceAdd () throws IOException {
139+ Table table = TestTables .create (temp , "test" , SCHEMA , SPEC , formatVersion );
140+
141+ DataFile fileOne = createDataFile ("one" );
142+ DataFile fileTwo = createDataFile ("two" );
143+
144+ table .newAppend ().appendFile (fileOne ).appendFile (fileTwo ).commit ();
145+ long firstSnapshotId = table .currentSnapshot ().snapshotId ();
146+
147+ List <FileScanTask > tasks =
148+ Lists .newArrayList (table .newScan ().filter (Expressions .equal ("part" , "one" )).planFiles ());
149+
150+ assertThat (tasks ).hasSize (1 );
151+
152+ // add a new partition column
153+ table .updateSchema ().addColumn ("hour" , Types .IntegerType .get ()).commit ();
154+ table .updateSpec ().addField ("hour" ).commit ();
155+
156+ // plan the scan using the new column in a filter
157+ tasks = Lists .newArrayList (table .newScan ().filter (Expressions .isNull ("hour" )).planFiles ());
158+
159+ assertThat (tasks ).hasSize (2 );
160+
161+ // create a new commit
162+ table .newAppend ().appendFile (createDataFile ("three" )).commit ();
163+
164+ // plan the scan using the existing column in a filter
165+ tasks =
166+ Lists .newArrayList (
167+ table
168+ .newScan ()
169+ .useSnapshot (firstSnapshotId )
170+ .filter (Expressions .equal ("part" , "one" ))
171+ .planFiles ());
172+
173+ assertThat (tasks ).hasSize (1 );
174+ }
175+
137176 @ TestTemplate
138177 public void testPartitionSourceDrop () throws IOException {
139178 Table table = TestTables .create (temp , "test" , SCHEMA , SPEC , formatVersion );
@@ -179,6 +218,37 @@ public void testPartitionSourceDrop() throws IOException {
179218 .collect (Collectors .toList ()));
180219 }
181220
221+ @ TestTemplate
222+ public void testColumnAdd () throws IOException {
223+ Table table = TestTables .create (temp , "test" , SCHEMA , SPEC , formatVersion );
224+
225+ DataFile fileOne = createDataFile ("one" );
226+ DataFile fileTwo = createDataFile ("two" );
227+
228+ table .newAppend ().appendFile (fileOne ).appendFile (fileTwo ).commit ();
229+ long firstSnapshotId = table .currentSnapshot ().snapshotId ();
230+
231+ table .updateSchema ().addColumn ("hour" , Types .IntegerType .get ()).commit ();
232+
233+ DataFile fileThree = createDataFile ("three" , table .schema (), table .spec ());
234+ table .newAppend ().appendFile (fileThree ).commit ();
235+
236+ // plan the scan using the new column in a filter
237+ List <FileScanTask > tasks =
238+ Lists .newArrayList (table .newScan ().filter (Expressions .isNull ("hour" )).planFiles ());
239+ assertThat (tasks ).hasSize (3 );
240+
241+ // plan the scan using the existing column in a filter
242+ tasks =
243+ Lists .newArrayList (
244+ table
245+ .newScan ()
246+ .useSnapshot (firstSnapshotId )
247+ .filter (Expressions .equal ("data" , "xyz" ))
248+ .planFiles ());
249+ assertThat (tasks ).hasSize (2 );
250+ }
251+
182252 @ TestTemplate
183253 public void testColumnRename () throws IOException {
184254 Table table = TestTables .create (temp , "test" , SCHEMA , SPEC , formatVersion );
0 commit comments