diff --git hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java index cf15ff2..bd3d6e2 100644 --- hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java +++ hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java @@ -240,6 +240,21 @@ public void testAlterTblClusteredBy() throws CommandNeedRetryException { } @Test + public void testAlterTableRename() throws CommandNeedRetryException, TException { + hcatDriver.run("drop table oldname"); + hcatDriver.run("drop table newname"); + hcatDriver.run("create table oldname (a int)"); + Table tbl = client.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, "oldname"); + assertTrue(tbl.getSd().getLocation().contains("oldname")); + + hcatDriver.run("alter table oldname rename to newNAME"); + tbl = client.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, "newname"); + assertTrue(tbl.getSd().getLocation().contains("newname")); + + hcatDriver.run("drop table newname"); + } + + @Test public void testAlterTableSetFF() throws IOException, MetaException, TException, NoSuchObjectException, CommandNeedRetryException { hcatDriver.run("drop table junit_sem_analysis"); diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java index 016926b..0652b9d 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java @@ -180,7 +180,7 @@ public void alterTable(RawStore msdb, Warehouse wh, String dbname, // get new location Database db = msdb.getDatabase(newt.getDbName()); Path databasePath = constructRenamedPath(wh.getDatabasePath(db), srcPath); - destPath = new Path(databasePath, newt.getTableName()); + destPath = new Path(databasePath, newt.getTableName().toLowerCase()); destFs = wh.getFs(destPath); newt.getSd().setLocation(destPath.toString());