You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jd...@apache.org on 2016/03/03 21:41:27 UTC

hive git commit: HIVE-13186: ALTER TABLE RENAME should lowercase table name and hdfs location (Wei Zheng via Jason Dere)

Repository: hive
Updated Branches:
  refs/heads/master 2618e1879 -> 493a6b3a5


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/493a6b3a
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/493a6b3a
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/493a6b3a

Branch: refs/heads/master
Commit: 493a6b3a59dcd25997fde81662e1f917e1eb3400
Parents: 2618e18
Author: Jason Dere <jd...@hortonworks.com>
Authored: Thu Mar 3 12:40:03 2016 -0800
Committer: Jason Dere <jd...@hortonworks.com>
Committed: Thu Mar 3 12:40:03 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/493a6b3a/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 cf15ff2..bd3d6e2 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
@@ -240,6 +240,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/493a6b3a/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 016926b..0652b9d 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
@@ -180,7 +180,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());