rdblue commented on a change in pull request #3469:
URL: https://github.com/apache/iceberg/pull/3469#discussion_r753328577



##########
File path: 
spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/actions/TestCreateActions.java
##########
@@ -586,8 +594,36 @@ private void createSourceTable(String createStatement, 
String tableName)
   }
 
   // Counts the number of files in the source table, makes sure the same files 
exist in the destination table
-  private void assertMigratedFileCount(CreateAction migrateAction, String 
source, String dest)
+  private void assertMigratedFileCount(MigrateTable migrateAction, String 
source, String dest)
       throws NoSuchTableException, NoSuchDatabaseException, ParseException {
+    long expectedFiles = getExpectedFiles(source);
+    MigrateTable.Result migratedFiles = migrateAction.execute();
+    validateTables(source, dest);
+    Assert.assertEquals("Expected number of migrated files",
+        expectedFiles, migratedFiles.migratedDataFilesCount());
+  }
+
+  // Counts the number of files in the source table, makes sure the same files 
exist in the destination table
+  private void assertSnapshotFileCount(SnapshotTable snapshotTable, String 
source, String dest)
+      throws NoSuchTableException, NoSuchDatabaseException, ParseException {
+    long expectedFiles = getExpectedFiles(source);
+    SnapshotTable.Result snapshotTableResult = snapshotTable.execute();
+    validateTables(source, dest);
+    Assert.assertEquals("Expected number of imported snapshot files", 
expectedFiles,
+        snapshotTableResult.importedDataFilesCount());
+  }
+
+  private void validateTables(String source, String dest) throws 
NoSuchTableException, ParseException {
+    List<Row> expected = spark.table(source).collectAsList();
+    SparkTable destTable = loadTable(dest);
+    Assert.assertEquals("Provider should be iceberg", "iceberg",
+        destTable.properties().get(TableCatalog.PROP_PROVIDER));
+    List<Row> actual = spark.table(dest).collectAsList();
+    Assert.assertTrue(String.format("Rows in migrated table did not 
match\nExpected :%s rows \nFound    :%s",
+        expected, actual), expected.containsAll(actual) && 
actual.containsAll(expected));
+  }
+
+  private long getExpectedFiles(String source) throws NoSuchDatabaseException, 
NoSuchTableException, ParseException {

Review comment:
       Is there a better verb than `get` that describes what's actually 
happening here? We avoid get because it is typically vague and not helpful.




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

To unsubscribe, e-mail: [email protected]

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