Repository: hive Updated Branches: refs/heads/branch-1 9bcda26da -> b6c1026d7
HIVE-13186: ALTER TABLE RENAME should lowercase table name and hdfs location (Wei Zheng via Jason Dere) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b6c1026d Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b6c1026d Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b6c1026d Branch: refs/heads/branch-1 Commit: b6c1026d7e8ad8fe9b03e11aaba5e3f1fe76e540 Parents: 9bcda26 Author: Jason Dere <[email protected]> Authored: Thu Mar 3 12:49:31 2016 -0800 Committer: Jason Dere <[email protected]> Committed: Thu Mar 3 12:49:31 2016 -0800 ---------------------------------------------------------------------- .../hive/hcatalog/cli/TestSemanticAnalysis.java | 15 +++++++++++++++ .../hadoop/hive/metastore/HiveAlterHandler.java | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/b6c1026d/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java ---------------------------------------------------------------------- diff --git a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java index 606cb3a..dbf94de 100644 --- a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java +++ b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestSemanticAnalysis.java @@ -239,6 +239,21 @@ public class TestSemanticAnalysis extends HCatBaseTest { } @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"); http://git-wip-us.apache.org/repos/asf/hive/blob/b6c1026d/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java ---------------------------------------------------------------------- diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java index f67f2df..c059f5e 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java @@ -177,7 +177,7 @@ public class HiveAlterHandler implements AlterHandler { // 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());
