You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hcatalog-commits@incubator.apache.org by av...@apache.org on 2012/08/24 18:09:22 UTC

svn commit: r1377018 - in /incubator/hcatalog/branches/branch-0.4: CHANGES.txt webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java

Author: avandana
Date: Fri Aug 24 18:09:22 2012
New Revision: 1377018

URL: http://svn.apache.org/viewvc?rev=1377018&view=rev
Log:
HCAT-477 Drop table API in webhcat client does not respect the ifExists parameter.(for branch)

Modified:
    incubator/hcatalog/branches/branch-0.4/CHANGES.txt
    incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java
    incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java

Modified: incubator/hcatalog/branches/branch-0.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.4/CHANGES.txt?rev=1377018&r1=1377017&r2=1377018&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.4/CHANGES.txt (original)
+++ incubator/hcatalog/branches/branch-0.4/CHANGES.txt Fri Aug 24 18:09:22 2012
@@ -61,6 +61,8 @@ Trunk (unreleased changes)
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-477 Drop table API in webhcat client does not respect the "ifExists" parameter.
+
   HCAT-471 Test HCat_ShowDes_1[1-3] fails (vikram.dixit via gates)
 
   HCAT-451 Partitions are created even when Jobs are aborted (avandana)

Modified: incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java?rev=1377018&r1=1377017&r2=1377018&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java (original)
+++ incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/main/java/org/apache/hcatalog/api/HCatClientHMSImpl.java Fri Aug 24 18:09:22 2012
@@ -238,7 +238,7 @@ public class HCatClientHMSImpl extends H
     public void dropTable(String dbName, String tableName, boolean ifExists)
             throws HCatException, ConnectionFailureException {
         try {
-            hmsClient.dropTable(checkDB(dbName), tableName);
+            hmsClient.dropTable(checkDB(dbName), tableName,true, ifExists);
         } catch (NoSuchObjectException e) {
             if (!ifExists) {
                 throw new HCatException(

Modified: incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java?rev=1377018&r1=1377017&r2=1377018&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java (original)
+++ incubator/hcatalog/branches/branch-0.4/webhcat/java-client/src/test/java/org/apache/hcatalog/api/TestHCatClient.java Fri Aug 24 18:09:22 2012
@@ -24,8 +24,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 
-import junit.framework.TestCase;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStore;
@@ -36,15 +34,12 @@ import org.apache.hadoop.hive.ql.io.RCFi
 import org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe;
 import org.apache.hadoop.mapred.TextInputFormat;
 import org.apache.hcatalog.cli.SemanticAnalysis.HCatSemanticAnalyzer;
-import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hcatalog.common.HCatException;
 import org.apache.hcatalog.data.schema.HCatFieldSchema;
 import org.apache.hcatalog.data.schema.HCatFieldSchema.Type;
-import org.apache.hcatalog.ExitException;
 import org.apache.hcatalog.NoExitSecurityManager;
 import org.junit.AfterClass;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -77,7 +72,7 @@ public class TestHCatClient {
     }
 
     @BeforeClass
-    public static void setUp() throws Exception {
+    public static void startMetaStoreServer() throws Exception {
 
         Thread t = new Thread(new RunMS());
         t.start();
@@ -357,4 +352,22 @@ public class TestHCatClient {
             assertTrue("The expected exception was never thrown.", isExceptionCaught);
         }
     }
+
+    @Test
+    public void testDropTableException() throws Exception {
+        HCatClient client = HCatClient.create(new Configuration(hcatConf));
+        String tableName = "tableToBeDropped";
+        boolean isExceptionCaught = false;
+        client.dropTable(null, tableName, true);
+        try {
+            client.dropTable(null, tableName, false);
+        } catch (Exception exp) {
+            isExceptionCaught = true;
+            assertTrue(exp instanceof HCatException);
+            LOG.info("Drop Table Exception: " + exp.getCause());
+        } finally {
+            client.close();
+            assertTrue("The expected exception was never thrown.", isExceptionCaught);
+        }
+    }
 }