karuppayya commented on a change in pull request #2087:
URL: https://github.com/apache/iceberg/pull/2087#discussion_r557483107



##########
File path: 
spark3/src/test/java/org/apache/iceberg/actions/TestCreateActions.java
##########
@@ -296,14 +406,25 @@ private void createSourceTable(String createStatement, 
String tableName)
   private void assertMigratedFileCount(CreateAction migrateAction, String 
source, String dest)
       throws NoSuchTableException, NoSuchDatabaseException, ParseException {
     CatalogTable sourceTable = loadSessionTable(source);
-    Path sourceDir = Paths.get(sourceTable.location());
-    List<File> files = FileUtils.listFiles(sourceDir.toFile(), 
TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)
-        .stream()
-        .filter(file -> !file.toString().endsWith("crc") && 
!file.toString().contains("_SUCCESS"))
-        .collect(Collectors.toList());
-    long expectedMigratedFiles = files.size();
-    List<Row> expected = spark.table(source).collectAsList();
+    List<URI> uris;
+    if (sourceTable.partitionColumnNames().size() == 0) {
+      uris = new ArrayList<>();
+      uris.add(sourceTable.location());
+    } else {
+      Seq<CatalogTablePartition> catalogTablePartitionSeq =
+              
spark.sessionState().catalog().listPartitions(sourceTable.identifier(), 
Option.apply(null));
+      uris = JavaConverters.seqAsJavaList(catalogTablePartitionSeq)
+              .stream()
+              .map(CatalogTablePartition::location)
+              .collect(Collectors.toList());
+    }
+    long expectedMigratedFiles = uris.stream()

Review comment:
       For the tests regarding unrecovered partitions(one of the new test 
case), the total file count should be that of only those those registered in 
metastore. With the prior change, it does a root level listing, counting files 
from unrecovered partitions as well.




----------------------------------------------------------------
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