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



##########
File path: 
spark3/src/test/java/org/apache/iceberg/actions/TestCreateActions.java
##########
@@ -157,6 +170,192 @@ public void testMigratePartitioned() throws Exception {
     assertMigratedFileCount(Actions.migrate(source), source, dest);
   }
 
+  @Test
+  public void testPartitionedTableWithUnRecoveredPartitions() throws Exception 
{
+    Assume.assumeTrue("Cannot migrate to a hadoop based catalog", 
!type.equals("hadoop"));
+    Assume.assumeTrue("Can only migrate from Spark Session Catalog", 
catalog.name().equals("spark_catalog"));
+    String source = sourceName("test_unrecovered_partitions");
+    String dest = source;
+    File location = temp.newFolder();
+    sql(CREATE_PARTITIONED_PARQUET, source, location);
+
+    // Data generation and partition addition
+    spark.range(5)
+        .selectExpr("id", "cast(id as STRING) as data")
+        .write()
+        .partitionBy("id").mode(SaveMode.Overwrite)
+        .parquet(location.toURI().toString());
+    sql("ALTER TABLE %s ADD PARTITION(id=0)", source);
+
+    assertMigratedFileCount(Actions.migrate(source), source, dest);
+  }
+
+  @Test
+  public void testPartitionedTableWithCustomPartitions() throws Exception {
+    Assume.assumeTrue("Cannot migrate to a hadoop based catalog", 
!type.equals("hadoop"));
+    Assume.assumeTrue("Can only migrate from Spark Session Catalog", 
catalog.name().equals("spark_catalog"));
+    String source = sourceName("test_custom_parts");
+    String dest = source;
+    File tblLocation = temp.newFolder();
+    File partitionDataLoc = temp.newFolder();
+
+    // Data generation and partition addition
+    spark.sql(String.format(CREATE_PARTITIONED_PARQUET, source, tblLocation));
+    spark.range(10)
+        .selectExpr("cast(id as STRING) as data")
+        .write()
+        .mode(SaveMode.Overwrite).parquet(partitionDataLoc.toURI().toString());
+    spark.sql(String.format("ALTER TABLE %s ADD PARTITION(id=0) LOCATION 
'%s'", source,
+        partitionDataLoc.toURI().toString()));
+    assertMigratedFileCount(Actions.migrate(source), source, dest);
+  }
+
+  @Test
+  public void testAddColumnOnMigratedTable() throws Exception {
+    testAddColumnOnMigratedTableAtEnd();
+    testAddColumnOnMigratedTableAtMiddle();
+  }
+
+  private void testAddColumnOnMigratedTableAtEnd() throws Exception {
+    Assume.assumeTrue("Cannot migrate to a hadoop based catalog", 
!type.equals("hadoop"));
+    Assume.assumeTrue("Can only migrate from Spark Session Catalog", 
catalog.name().equals("spark_catalog"));
+    String source = sourceName("test_add_column_migrated_table");
+    String dest = source;
+    createSourceTable(CREATE_PARQUET, source);
+    List<Object[]> expected1 = sql("select *, null from %s order by id", dest);
+    List<Object[]> expected2 = sql("select *, null, null from %s order by id", 
dest);
+
+    // migrate table
+    Actions.migrate(source).execute();

Review comment:
       Got it, I missed it.




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