tomtongue commented on code in PR #8931:
URL: https://github.com/apache/iceberg/pull/8931#discussion_r1375265726


##########
spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestMigrateTableProcedure.java:
##########
@@ -142,6 +142,48 @@ public void testMigrateWithBackupTableName() throws 
IOException {
     Assertions.assertThat(spark.catalog().tableExists(dbName + "." + 
backupTableName)).isTrue();
   }
 
+  @Test
+  public void testMigrateWithDestCatalogName() throws IOException {
+    Assume.assumeTrue(catalogName.equals("spark_catalog"));
+
+    spark
+        .conf()
+        .set("spark.sql.catalog.spark_catalog", 
"org.apache.iceberg.spark.SparkSessionCatalog");
+
+    String location = temp.newFolder().toString();
+    sql(
+        "CREATE TABLE %s (id bigint NOT NULL, data string) USING parquet 
LOCATION '%s'",
+        tableName, location);
+    sql("INSERT INTO TABLE %s VALUES (1, 'a')", tableName);
+
+    Object result =
+        scalarSql(
+            "CALL %s.system.migrate(table => '%s', drop_backup => false, 
dest_catalog_name => '%s')",
+            catalogName, tableName, catalogName);
+    Assertions.assertThat(result).isEqualTo(1L);
+    Assertions.assertThat(spark.catalog().tableExists(tableName + 
"_BACKUP_")).isTrue();
+  }
+
+  @Test
+  public void testMigrateWithDestCatalogNameWithNonExistingCatalog() throws 
IOException {
+    Assume.assumeTrue(catalogName.equals("spark_catalog"));
+
+    String destCatalogName = "non_existing_catalog";
+
+    String location = temp.newFolder().toString();
+    sql(
+        "CREATE TABLE %s (id bigint NOT NULL, data string) USING parquet 
LOCATION '%s'",
+        tableName, location);
+    sql("INSERT INTO TABLE %s VALUES (1, 'a')", tableName);
+
+    Object result =
+        scalarSql(
+            "CALL %s.system.migrate(table => '%s', drop_backup => false, 
dest_catalog_name => '%s')",
+            catalogName, tableName, destCatalogName);
+    Assertions.assertThat(result).isEqualTo(1L);
+    Assertions.assertThat(spark.catalog().tableExists(tableName + 
"_BACKUP_")).isTrue();

Review Comment:
   I believe that it's better to throw an exception for specifying non-existing 
catalog name as you're suggesting. So change the dest catalog check handling, 
and also change the test to follow the dest catalog change. Thanks!



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