hadoop-hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zs...@apache.org
Subject svn commit: r726161 - in /hadoop/hive/trunk: CHANGES.txt metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
Date Sat, 13 Dec 2008 03:05:08 GMT
Author: zshao
Date: Fri Dec 12 19:05:06 2008
New Revision: 726161

URL: http://svn.apache.org/viewvc?rev=726161&view=rev
Log:
HIVE-114. Drop partition does not delete data for external tables now.
(Johan Oskarsson via zshao)

Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
    hadoop/hive/trunk/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=726161&r1=726160&r2=726161&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Fri Dec 12 19:05:06 2008
@@ -36,6 +36,9 @@
 
   BUG FIXES
 
+    HIVE-114. Drop partition does not delete data for external tables now.
+    (Johan Oskarsson via zshao)
+
     HIVE-144. Hive/ql java source copied to build/ql/java to make it work 
     with eclipse. (Johan Oskarsson via zshao)
 

Modified: hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java?rev=726161&r1=726160&r2=726161&view=diff
==============================================================================
--- hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
(original)
+++ hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
Fri Dec 12 19:05:06 2008
@@ -340,6 +340,11 @@
         }
       }
 
+      /**
+       * Is this an external table?
+       * @param table Check if this table is external.
+       * @return True if the table is external, otherwise false.
+       */
       private boolean isExternal(Table table) {
         if(table == null) {
           return false;
@@ -480,6 +485,7 @@
         LOG.info("Partition values:" + part_vals);
         boolean success = false;
         Path partPath = null;
+        Table tbl = null;
         try {
           getMS().openTransaction();
           Partition part = this.get_partition(db_name, tbl_name, part_vals);
@@ -494,12 +500,15 @@
           }
           success  = getMS().commitTransaction();
           partPath = new Path(part.getSd().getLocation());
+          tbl = get_table(db_name, tbl_name);
         } finally {
           if(!success) {
             getMS().rollbackTransaction();
           } else if(deleteData && (partPath != null)) {
-            wh.deleteDir(partPath, true);
-            // ok even if the data is not deleted
+            if(tbl != null && !isExternal(tbl)) {
+              wh.deleteDir(partPath, true);
+              // ok even if the data is not deleted
+            }
           }
         }
         return true;

Modified: hadoop/hive/trunk/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java?rev=726161&r1=726160&r2=726161&view=diff
==============================================================================
--- hadoop/hive/trunk/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
(original)
+++ hadoop/hive/trunk/metastore/src/test/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
Fri Dec 12 19:05:06 2008
@@ -125,6 +125,7 @@
     part.setParameters(new HashMap<String, String>());
     part.setSd(tbl.getSd());
     part.getSd().setSerdeInfo(tbl.getSd().getSerdeInfo());
+    part.getSd().setLocation(tbl.getSd().getLocation() + "/part1");
   
     Partition retp = client.add_partition(part);
     assertNotNull("Unable to create partition " + part, retp);
@@ -132,8 +133,13 @@
     Partition part2 = client.getPartition(dbName, tblName, part.getValues());
     assertTrue("Partitions are not same",part.equals(part2));
   
+    FileSystem fs = FileSystem.get(this.hiveConf);
+    Path partPath = new Path(part2.getSd().getLocation());
+    
+    assertTrue(fs.exists(partPath));
     ret = client.dropPartition(dbName, tblName, part.getValues(), true);
     assertTrue(ret);
+    assertFalse(fs.exists(partPath));
   
     // add the partition again so that drop table with a partition can be tested
     retp = client.add_partition(part);
@@ -143,7 +149,17 @@
   
     ret = client.dropType(typeName);
     assertTrue("Unable to drop type " + typeName, ret);
-  
+
+    //recreate table as external, drop partition and it should
+    //still exist
+    tbl.setParameters(new HashMap<String, String>());
+    tbl.getParameters().put("EXTERNAL", "TRUE");
+    client.createTable(tbl);
+    retp = client.add_partition(part);
+    assertTrue(fs.exists(partPath));
+    client.dropPartition(dbName, tblName, part.getValues(), true);
+    assertTrue(fs.exists(partPath));
+    
     ret = client.dropDatabase(dbName);
     assertTrue("Unable to create the databse " + dbName, ret);
     } catch (Exception e) {



Mime
View raw message