/** * Drop a database * @param name * @param deleteData * @param ignoreUnknownDb if true, will ignore NoSuchObjectException * @throws HiveException * @throws NoSuchObjectException */ public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb) throws HiveException, NoSuchObjectException { dropDatabase(name, deleteData, ignoreUnknownDb, false); }
/** * Drop a database. * @param name * @throws NoSuchObjectException * @throws HiveException * @see org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropDatabase(java.lang.String) */ public void dropDatabase(String name) throws HiveException, NoSuchObjectException { dropDatabase(name, true, false, false); }
/** * Drop a database * @param name * @param deleteData * @param ignoreUnknownDb if true, will ignore NoSuchObjectException * @throws HiveException * @throws NoSuchObjectException */ public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb) throws HiveException, NoSuchObjectException { dropDatabase(name, deleteData, ignoreUnknownDb, false); }
/** * Drop a database. * @param name * @throws NoSuchObjectException * @throws HiveException * @see org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropDatabase(java.lang.String) */ public void dropDatabase(String name) throws HiveException, NoSuchObjectException { dropDatabase(name, true, false, false); }
ss.err.println(String.format("Failed to set permissions and/or group on DB: <%s> %s", dbName, e.getMessage())); try { Hive.get().dropDatabase(dbName); } catch (Exception e1) { ss.err.println(String.format("Failed to drop DB <%s> after failing to set permissions/group on it. %s", dbName, e1.getMessage()));
/** * Drop a Database * @param db * @param dropDb * @return Always returns 0 * @throws HiveException */ private int dropDatabase(Hive db, DropDatabaseDesc dropDb) throws HiveException { try { String dbName = dropDb.getDatabaseName(); db.dropDatabase(dbName, true, dropDb.getIfExists(), dropDb.isCasdade()); // Unregister the functions as well if (dropDb.isCasdade()) { FunctionRegistry.unregisterPermanentFunctions(dbName); } } catch (NoSuchObjectException ex) { throw new HiveException(ex, ErrorMsg.DATABASE_NOT_EXISTS, dropDb.getDatabaseName()); } return 0; }
/** * Removes all databases and tables from the metastore */ public static void cleanupHMS(Hive hive, Warehouse wh, FsPermission defaultPerm) throws HiveException, MetaException, NoSuchObjectException { for (String dbName : hive.getAllDatabases()) { if (dbName.equals("default")) { continue; } try { Path path = getDbPath(hive, wh, dbName); FileSystem whFs = path.getFileSystem(hive.getConf()); whFs.setPermission(path, defaultPerm); } catch (IOException ex) { //ignore } hive.dropDatabase(dbName, true, true, true); } //clean tables in default db for (String tablename : hive.getAllTables("default")) { hive.dropTable("default", tablename, true, true); } }
@Test public void testDataDeletion() throws HiveException, IOException, TException { Database db = new Database(); db.setName(dbName); hive.createDatabase(db); Table table = new Table(dbName, tableName); table.setDbName(dbName); table.setInputFormatClass(TextInputFormat.class); table.setOutputFormatClass(HiveIgnoreKeyTextOutputFormat.class); table.setPartCols(partCols); hive.createTable(table); table = hive.getTable(dbName, tableName); Path fakeTable = table.getPath().getParent().suffix( Path.SEPARATOR + "faketable"); fs = fakeTable.getFileSystem(hive.getConf()); fs.mkdirs(fakeTable); fs.deleteOnExit(fakeTable); Path fakePart = new Path(table.getDataLocation().toString(), "fakepartition=fakevalue"); fs.mkdirs(fakePart); fs.deleteOnExit(fakePart); hive.dropTable(dbName, tableName, true, true); assertFalse(fs.exists(fakePart)); hive.dropDatabase(dbName); assertFalse(fs.exists(fakeTable)); }
String dbName = "db_for_testgettables"; String table1Name = "table1"; hm.dropDatabase(dbName, true, true, true); assertFalse(fs.exists(table.getPath())); hm.dropDatabase(dbName); } catch (Throwable e) { System.err.println(StringUtils.stringifyException(e));
hm.dropDatabase(dbName, true, true, true); assertFalse(fs.exists(table.getPath())); hm.dropDatabase(dbName); } catch (Throwable e) { System.err.println(StringUtils.stringifyException(e));
/** * Drop a Database * @param db * @param dropDb * @return Always returns 0 * @throws HiveException */ private int dropDatabase(Hive db, DropDatabaseDesc dropDb) throws HiveException { try { String dbName = dropDb.getDatabaseName(); ReplicationSpec replicationSpec = dropDb.getReplicationSpec(); if (replicationSpec.isInReplicationScope()) { Database database = db.getDatabase(dbName); if (database == null || !replicationSpec.allowEventReplacementInto(database.getParameters())) { return 0; } } db.dropDatabase(dbName, true, dropDb.getIfExists(), dropDb.isCasdade()); // Unregister the functions as well if (dropDb.isCasdade()) { FunctionRegistry.unregisterPermanentFunctions(dbName); } } catch (NoSuchObjectException ex) { throw new HiveException(ex, ErrorMsg.DATABASE_NOT_EXISTS, dropDb.getDatabaseName()); } return 0; }
/** * Drop a database * @param name * @param deleteData * @param ignoreUnknownDb if true, will ignore NoSuchObjectException * @throws HiveException * @throws NoSuchObjectException */ public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb) throws HiveException, NoSuchObjectException { dropDatabase(name, deleteData, ignoreUnknownDb, false); }
/** * Drop a database. * @param name * @throws NoSuchObjectException * @throws HiveException * @see org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropDatabase(java.lang.String) */ public void dropDatabase(String name) throws HiveException, NoSuchObjectException { dropDatabase(name, true, false); }
/** * Drop a database. * @param name * @throws NoSuchObjectException * @throws HiveException * @see org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropDatabase(java.lang.String) */ public void dropDatabase(String name) throws HiveException, NoSuchObjectException { dropDatabase(name, true, false, false); }
db.dropDatabase(dbName, true, true, true);
/** * Drop a Database * @param db * @param dropDb * @return Always returns 0 * @throws HiveException * @throws NoSuchObjectException */ private int dropDatabase(Hive db, DropDatabaseDesc dropDb) throws HiveException, NoSuchObjectException { db.dropDatabase(dropDb.getDatabaseName(), true, dropDb.getIfExists()); return 0; }
/** * Tear down. * * @throws HiveException the hive exception * @throws NoSuchObjectException the no such object exception */ @AfterTest public void tearDown() throws HiveException, NoSuchObjectException { Hive client = Hive.get(conf); client.dropDatabase(TestDBStorage.class.getSimpleName(), true, true, true); }
@AfterClass public static void teardown() throws Exception { // Drop the cube client.dropCube(CUBE_NAME); client.dropCube(VIRTUAL_CUBE_NAME); client = CubeMetastoreClient.getInstance(conf); assertFalse(client.tableExists(CUBE_NAME)); Hive.get().dropDatabase(TestCubeMetastoreClient.class.getSimpleName(), true, true, true); CubeMetastoreClient.close(); }
/** * After test. * * @throws Exception the exception */ @AfterTest public void afterTest() throws Exception { verifyThriftLogs(); driver.close(); Hive.get(hiveConf).dropDatabase(dataBase, true, true, true); }
@AfterTest public void tearDown() throws Exception { super.tearDown(); Hive hive = Hive.get(new HiveConf()); hive.dropDatabase(TEST_DB); mlClient.close(); }