@@ -160,8 +160,7 @@ public void testGetCurrentSnapshot(@TempDir Path workingDir) throws IOException
160160 PartitionValue partitionEntry = partitionValues .iterator ().next ();
161161 assertEquals (
162162 "cs_sold_date_sk" , partitionEntry .getPartitionField ().getSourceField ().getName ());
163- // TODO generate test with column stats
164- assertEquals (0 , internalDataFile .getColumnStats ().size ());
163+ assertEquals (7 , internalDataFile .getColumnStats ().size ());
165164 }
166165 }
167166
@@ -202,12 +201,12 @@ public void testGetTableChangeForCommit(@TempDir Path workingDir) throws IOExcep
202201 Snapshot snapshot5 = catalogSales .currentSnapshot ();
203202 Snapshot snapshot4 = catalogSales .snapshot (snapshot5 .parentId ());
204203
205- validateTableChangeDiffSize (catalogSales , snapshot1 , 5 , 0 );
206- validateTableChangeDiffSize (catalogSales , snapshot2 , 0 , 3 );
207- validateTableChangeDiffSize (catalogSales , snapshot3 , 5 , 0 );
204+ validateTableChangeDiffSize (catalogSales , snapshot1 , 5 , 0 , 7 );
205+ validateTableChangeDiffSize (catalogSales , snapshot2 , 0 , 3 , 7 );
206+ validateTableChangeDiffSize (catalogSales , snapshot3 , 5 , 0 , 7 );
208207 // transaction related snapshot verification
209- validateTableChangeDiffSize (catalogSales , snapshot4 , 0 , 1 );
210- validateTableChangeDiffSize (catalogSales , snapshot5 , 1 , 0 );
208+ validateTableChangeDiffSize (catalogSales , snapshot4 , 0 , 1 , 7 );
209+ validateTableChangeDiffSize (catalogSales , snapshot5 , 1 , 0 , 7 );
211210
212211 assertEquals (4 , catalogSales .history ().size ());
213212 catalogSales .expireSnapshots ().expireSnapshotId (snapshot1 .snapshotId ()).commit ();
@@ -242,7 +241,7 @@ public void testGetTableChangeForCommit(@TempDir Path workingDir) throws IOExcep
242241 catalogSales .updateSpec ().removeField ("cs_sold_date_sk" ).commit ();
243242 Snapshot snapshot8 = catalogSales .currentSnapshot ();
244243
245- validateTableChangeDiffSize (catalogSales , snapshot7 , 1 , 2 );
244+ validateTableChangeDiffSize (catalogSales , snapshot7 , 1 , 2 , 7 );
246245 assertEquals (snapshot7 , snapshot8 );
247246 }
248247
@@ -311,10 +310,13 @@ private static long getDataFileCount(Table catalogSales) throws IOException {
311310 }
312311
313312 private void validateTableChangeDiffSize (
314- Table table , Snapshot snapshot , int addedFiles , int removedFiles ) {
313+ Table table , Snapshot snapshot , int addedFiles , int removedFiles , int numberOfColumns ) {
315314 IcebergConversionSource conversionSource = getIcebergConversionSource (table );
316315 TableChange tableChange = conversionSource .getTableChangeForCommit (snapshot );
317316 assertEquals (addedFiles , tableChange .getFilesDiff ().getFilesAdded ().size ());
317+ assertTrue (
318+ tableChange .getFilesDiff ().getFilesAdded ().stream ()
319+ .allMatch (file -> file .getColumnStats ().size () == numberOfColumns ));
318320 assertEquals (removedFiles , tableChange .getFilesDiff ().getFilesRemoved ().size ());
319321 }
320322
0 commit comments