manishmalhotrawork commented on a change in pull request #1471:
URL: https://github.com/apache/iceberg/pull/1471#discussion_r490542593



##########
File path: 
spark/src/test/java/org/apache/iceberg/actions/TestRemoveOrphanFilesAction.java
##########
@@ -569,4 +672,349 @@ public void testRemoveOrphanFilesWithHadoopCatalog() 
throws InterruptedException
         .collectAsList();
     Assert.assertEquals("Rows must match", records, actualRecords);
   }
+
+  @Test
+  public void testFindOrphanFilesWithSameAuthority() throws Exception {
+    List<Row> validFilesData = 
getRowsWithFilePath(HDFS_SERVICENAME_USER_LOG_DATA_DUMMY_FILE, 3);
+
+    Dataset<Row> validFileDS = RemoveOrphanFilesAction
+        .addRelativePathColumn(
+            spark.createDataset(validFilesData, 
RowEncoder.apply(constructStructureWithString())));
+
+    List<Row> actualFilesData = new ArrayList<>();
+
+    actualFilesData.addAll(validFilesData);
+    List<Row> expectedOrphanFiles = 
getRowsWithFilePath(HDFS_SERVICENAME_USER_LOG_DATA_ORPHAN_FILE, 4);
+    actualFilesData.addAll(expectedOrphanFiles);
+
+    Dataset<Row> actualFileDS = RemoveOrphanFilesAction
+        .addRelativePathColumn(
+            spark.createDataset(actualFilesData, 
RowEncoder.apply(constructStructureWithString())));
+
+    List<String> orphanFiles = 
RemoveOrphanFilesAction.findOrphanFiles(validFileDS, actualFileDS);
+
+    Assert.assertNotNull(orphanFiles);
+
+    Assert.assertEquals(expectedOrphanFiles.stream().map(row -> 
row.get(0).toString())
+        .collect(Collectors.toList()), orphanFiles);
+  }
+
+  @Test
+  public void testFindOrphanFilesWithValidFileHasNoAuthority() throws 
Exception {
+    List<Row> validFilesData = 
getRowsWithFilePath(HDFS_USER_LOG_DATA_DUMMY_FILE, 4);
+    Dataset<Row> validFileDS = RemoveOrphanFilesAction
+        .addRelativePathColumn(
+            spark.createDataset(validFilesData, 
RowEncoder.apply(constructStructureWithString())));
+
+    List<Row> actualFilesData = new ArrayList<>();
+
+    
actualFilesData.addAll(getRowsWithFilePath(HDFS_SERVICENAME_USER_LOG_DATA_DUMMY_FILE,
 4));
+    List<Row> expectedOrphanFiles = 
getRowsWithFilePath(HDFS_SERVICENAME_USER_LOG_DATA_ORPHAN_FILE, 4);
+    actualFilesData.addAll(expectedOrphanFiles);
+
+    Dataset<Row> actualFileDS = RemoveOrphanFilesAction
+        .addRelativePathColumn(
+            spark.createDataset(actualFilesData, 
RowEncoder.apply(constructStructureWithString())));
+
+    List<String> orphanFiles = 
RemoveOrphanFilesAction.findOrphanFiles(validFileDS, actualFileDS);
+
+    Assert.assertEquals(expectedOrphanFiles.stream().map(row -> 
row.get(0).toString())
+        .collect(Collectors.toList()), orphanFiles);
+  }
+
+  @Test

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to