zhangjun0x01 commented on code in PR #471:
URL: https://github.com/apache/flink-table-store/pull/471#discussion_r1067751874


##########
flink-table-store-hive/flink-table-store-hive-catalog/src/test/java/org/apache/flink/table/store/hive/HiveCatalogITCase.java:
##########
@@ -276,6 +279,36 @@ public void testFlinkWriteAndHiveRead() throws Exception {
         }
     }
 
+    @Test
+    public void testRenameTable() throws Exception {
+        tEnv.executeSql("CREATE TABLE t1 (a INT)").await();
+        tEnv.executeSql("CREATE TABLE t2 (a INT)").await();
+        tEnv.executeSql("INSERT INTO t1 VALUES(1)");
+
+        // the source table do not exist.
+        assertThatThrownBy(() -> tEnv.executeSql("ALTER TABLE t3 RENAME TO 
t4"))
+                .hasMessage(
+                        "Table `my_hive`.`test_db`.`t3` doesn't exist or is a 
temporary table.");
+
+        // the target table has existed.
+        assertThatThrownBy(() -> tEnv.executeSql("ALTER TABLE t1 RENAME TO 
t2"))
+                .hasMessage(
+                        "Could not execute ALTER TABLE my_hive.test_db.t1 
RENAME TO my_hive.test_db.t2");
+
+        tEnv.executeSql("ALTER TABLE t1 RENAME TO t3").await();
+        List<String> tables = hiveShell.executeQuery("SHOW TABLES");
+        Assert.assertTrue(tables.contains("t3"));
+        Assert.assertFalse(tables.contains("t1"));
+

Review Comment:
   > Maybe we can try to rename location after altering to hive metastore?
   
     I don't recommend this
   
   - The hive engine has done this operation. and there is no any problem, we 
don't need to repeat it 
   
   - This is a bug of HiveRunner, I test the lastest verion(6.0.1), I fount it 
is fine, the location is updated 
   correct,but if  we upgrade Hiverunner to lastest version, some test cases 
will fail, so I think we should add a todo issue to upgrade HiveRunner instead 
of manually renaming the location
   
   what do you think about ? 



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

Reply via email to