@@ -633,6 +633,61 @@ void testFileSlicingWithMultipleDeltaWriters() throws Exception {
633
633
assertEquals (deltaFile3 , logFiles .get (0 ).getFileName (), "Log File Order check" );
634
634
}
635
635
636
+ @ Test
637
+ void testLoadPartitions_unPartitioned () throws Exception {
638
+ String partitionPath = "" ;
639
+ Paths .get (basePath , partitionPath ).toFile ().mkdirs ();
640
+ String fileId = UUID .randomUUID ().toString ();
641
+
642
+ String instantTime1 = "1" ;
643
+ String fileName1 =
644
+ FSUtils .makeLogFileName (fileId , HoodieLogFile .DELTA_EXTENSION , instantTime1 , 0 , TEST_WRITE_TOKEN );
645
+
646
+ Paths .get (basePath , partitionPath , fileName1 ).toFile ().createNewFile ();
647
+ HoodieActiveTimeline commitTimeline = metaClient .getActiveTimeline ();
648
+ HoodieInstant instant1 = new HoodieInstant (true , HoodieTimeline .COMMIT_ACTION , instantTime1 );
649
+
650
+ saveAsComplete (commitTimeline , instant1 , Option .empty ());
651
+ refreshFsView ();
652
+
653
+ // Assert that no base files are returned without the partitions being loaded
654
+ assertEquals (0 , fsView .getLatestFileSliceInRange (Collections .singletonList ("1" )).count ());
655
+ // Assert that load does not fail for un-partitioned tables
656
+ fsView .loadPartitions (Collections .singletonList (partitionPath ));
657
+ // Assert that base files are returned after the empty-string partition is loaded
658
+ assertEquals (1 , fsView .getLatestFileSliceInRange (Collections .singletonList ("1" )).count ());
659
+ }
660
+
661
+ @ Test
662
+ void testLoadPartitions_partitioned () throws Exception {
663
+ String partitionPath1 = "2016/05/01" ;
664
+ String partitionPath2 = "2016/05/02" ;
665
+ Paths .get (basePath , partitionPath1 ).toFile ().mkdirs ();
666
+ Paths .get (basePath , partitionPath2 ).toFile ().mkdirs ();
667
+ String fileId1 = UUID .randomUUID ().toString ();
668
+ String fileId2 = UUID .randomUUID ().toString ();
669
+ String instantTime1 = "1" ;
670
+ String fileName1 =
671
+ FSUtils .makeLogFileName (fileId1 , HoodieLogFile .DELTA_EXTENSION , instantTime1 , 0 , TEST_WRITE_TOKEN );
672
+ String fileName2 =
673
+ FSUtils .makeLogFileName (fileId2 , HoodieLogFile .DELTA_EXTENSION , instantTime1 , 0 , TEST_WRITE_TOKEN );
674
+
675
+ Paths .get (basePath , partitionPath1 , fileName1 ).toFile ().createNewFile ();
676
+ Paths .get (basePath , partitionPath2 , fileName2 ).toFile ().createNewFile ();
677
+ HoodieActiveTimeline commitTimeline = metaClient .getActiveTimeline ();
678
+ HoodieInstant instant1 = new HoodieInstant (true , HoodieTimeline .COMMIT_ACTION , instantTime1 );
679
+
680
+ saveAsComplete (commitTimeline , instant1 , Option .empty ());
681
+ refreshFsView ();
682
+
683
+ // Assert that no base files are returned without the partitions being loaded
684
+ assertEquals (0 , fsView .getLatestFileSliceInRange (Collections .singletonList ("1" )).count ());
685
+ // Only load a single partition path
686
+ fsView .loadPartitions (Collections .singletonList (partitionPath1 ));
687
+ // Assert that base file is returned for partitionPath1 only
688
+ assertEquals (1 , fsView .getLatestFileSliceInRange (Collections .singletonList ("1" )).count ());
689
+ }
690
+
636
691
/**
637
692
* Returns all file-slices including uncommitted ones.
638
693
*
0 commit comments