Index: hbase-handler/src/test/results/negative/cascade_dbdrop.q.out
===================================================================
--- hbase-handler/src/test/results/negative/cascade_dbdrop.q.out (revision 0)
+++ hbase-handler/src/test/results/negative/cascade_dbdrop.q.out (working copy)
@@ -0,0 +1,22 @@
+PREHOOK: query: CREATE DATABASE hbaseDB
+PREHOOK: type: CREATEDATABASE
+POSTHOOK: query: CREATE DATABASE hbaseDB
+POSTHOOK: type: CREATEDATABASE
+PREHOOK: query: CREATE TABLE hbaseDB.hbase_table_0(key int, value string)
+STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
+WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:string")
+TBLPROPERTIES ("hbase.table.name" = "hbase_table_0")
+PREHOOK: type: CREATETABLE
+POSTHOOK: query: CREATE TABLE hbaseDB.hbase_table_0(key int, value string)
+STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
+WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:string")
+TBLPROPERTIES ("hbase.table.name" = "hbase_table_0")
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: hbaseDB@hbase_table_0
+Found 3 items
+#### A masked pattern was here ####
+PREHOOK: query: DROP DATABASE IF EXISTS hbaseDB CASCADE
+PREHOOK: type: DROPDATABASE
+POSTHOOK: query: DROP DATABASE IF EXISTS hbaseDB CASCADE
+POSTHOOK: type: DROPDATABASE
+Command failed with exit code = -1
Index: hbase-handler/src/test/queries/negative/cascade_dbdrop.q
===================================================================
--- hbase-handler/src/test/queries/negative/cascade_dbdrop.q (revision 0)
+++ hbase-handler/src/test/queries/negative/cascade_dbdrop.q (working copy)
@@ -0,0 +1,19 @@
+
+CREATE DATABASE hbaseDB;
+
+CREATE TABLE hbaseDB.hbase_table_0(key int, value string)
+STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
+WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:string")
+TBLPROPERTIES ("hbase.table.name" = "hbase_table_0");
+
+dfs -ls ../build/ql/tmp/hbase/hbase_table_0;
+
+DROP DATABASE IF EXISTS hbaseDB CASCADE;
+
+dfs -ls ../build/ql/tmp/hbase/hbase_table_0;
+
+
+
+
+
+
Index: hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
===================================================================
--- hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm (revision 0)
+++ hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm (working copy)
@@ -0,0 +1,119 @@
+package org.apache.hadoop.hive.cli;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.hadoop.hive.hbase.HBaseQTestUtil;
+import org.apache.hadoop.hive.hbase.HBaseTestSetup;
+import org.apache.hadoop.hive.ql.exec.Task;
+import org.apache.hadoop.hive.ql.history.HiveHistoryViewer;
+import org.apache.hadoop.hive.ql.history.HiveHistory.QueryInfo;
+import org.apache.hadoop.hive.ql.history.HiveHistory.Keys;
+import org.apache.hadoop.hive.ql.history.HiveHistory.TaskInfo;
+import org.apache.hadoop.hive.ql.session.SessionState;
+
+
+
+import org.antlr.runtime.*;
+import org.antlr.runtime.tree.*;
+
+public class $className extends TestCase {
+
+ private HBaseQTestUtil qt;
+ private HBaseTestSetup setup;
+
+ public $className(String name, HBaseTestSetup setup) {
+ super(name);
+ qt = null;
+ this.setup = setup;
+ }
+
+ @Override
+ protected void setUp() {
+ try {
+ boolean miniMR = false;
+ if ("$clusterMode".equals("miniMR")) {
+ miniMR = true;
+ }
+
+ qt = new HBaseQTestUtil(
+ "$resultsDir.getCanonicalPath()",
+ "$logDir.getCanonicalPath()", miniMR, setup);
+
+#foreach ($qf in $qfiles)
+ qt.addFile("$qf.getCanonicalPath()");
+#end
+ } catch (Exception e) {
+ System.out.println("Exception: " + e.getMessage());
+ e.printStackTrace();
+ System.out.flush();
+ fail("Unexpected exception in setup");
+ }
+ }
+
+ @Override
+ protected void tearDown() {
+ try {
+ qt.shutdown();
+ }
+ catch (Exception e) {
+ System.out.println("Exception: " + e.getMessage());
+ e.printStackTrace();
+ System.out.flush();
+ fail("Unexpected exception in tearDown");
+ }
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ HBaseTestSetup setup = new HBaseTestSetup(suite);
+#foreach ($qf in $qfiles)
+ #set ($fname = $qf.getName())
+ #set ($eidx = $fname.indexOf('.'))
+ #set ($tname = $fname.substring(0, $eidx))
+ suite.addTest(new $className("testCliDriver_$tname", setup));
+#end
+ return setup;
+ }
+
+#foreach ($qf in $qfiles)
+ #set ($fname = $qf.getName())
+ #set ($eidx = $fname.indexOf('.'))
+ #set ($tname = $fname.substring(0, $eidx))
+ public void testCliDriver_$tname() throws Exception {
+ long startTime = System.currentTimeMillis();
+ try {
+ System.out.println("Begin query: " + "$fname");
+ qt.cliInit("$fname");
+ qt.clearTestSideEffects();
+ int ecode = qt.executeClient("$fname");
+ if (ecode == 0) {
+ fail("Client Execution failed with error code = " + ecode);
+ }
+
+ ecode = qt.checkCliDriverResults("$fname");
+ if (ecode != 0) {
+ fail("Client execution results failed with error code = " + ecode);
+ }
+ qt.clearPostTestEffects();
+
+ } catch (Throwable e) {
+ System.out.println("Exception: " + e.getMessage());
+ e.printStackTrace();
+ System.out.println("Failed query: " + "$fname");
+ System.out.flush();
+ fail("Unexpected exception");
+ }
+
+ long elapsedTime = System.currentTimeMillis() - startTime;
+ System.out.println("Done query: " + "$fname" + " elapsedTime=" + elapsedTime/1000 + "s");
+ assertTrue("Test passed", true);
+ }
+
+#end
+}
+
Index: hbase-handler/build.xml
===================================================================
--- hbase-handler/build.xml (revision 1339908)
+++ hbase-handler/build.xml (working copy)
@@ -49,22 +49,31 @@
+
Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (revision 1339908)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (working copy)
@@ -458,6 +458,13 @@
}
return;
}
+
+ if (cascade) {
+ List tableList = getAllTables(name);
+ for (String table : tableList) {
+ dropTable(name, table, deleteData, false);
+ }
+ }
client.drop_database(name, deleteData, cascade);
}