org.apache.hadoop.hive.ql.metadata.Hive.dropDatabase()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(261)

本文整理了Java中org.apache.hadoop.hive.ql.metadata.Hive.dropDatabase()方法的一些代码示例,展示了Hive.dropDatabase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hive.dropDatabase()方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.metadata.Hive
类名称:Hive
方法名:dropDatabase

Hive.dropDatabase介绍

[英]Drop a database.
[中]删除数据库。

代码示例

代码示例来源:origin: apache/hive

/**
 * 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);
}

代码示例来源:origin: apache/hive

/**
 * 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);
}

代码示例来源:origin: apache/drill

/**
 * 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);
}

代码示例来源:origin: apache/drill

/**
 * 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);
}

代码示例来源:origin: apache/hive

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()));

代码示例来源:origin: apache/drill

/**
 * 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;
}

代码示例来源:origin: apache/hive

/**
 * 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);
 }
}

代码示例来源:origin: apache/hive

@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));
}

代码示例来源:origin: apache/hive

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));

代码示例来源:origin: apache/hive

hm.dropDatabase(dbName, true, true, true);
  assertFalse(fs.exists(table.getPath()));
 hm.dropDatabase(dbName);
} catch (Throwable e) {
 System.err.println(StringUtils.stringifyException(e));

代码示例来源:origin: apache/hive

/**
 * 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;
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

/**
 * 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);
}

代码示例来源:origin: org.apache.hadoop.hive/hive-exec

/**
 * 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);
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

/**
 * 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);
}

代码示例来源:origin: apache/phoenix

db.dropDatabase(dbName, true, true, true);

代码示例来源:origin: org.apache.hadoop.hive/hive-exec

/**
 * 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;
}

代码示例来源:origin: apache/lens

/**
 * 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);
}

代码示例来源:origin: apache/lens

@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();
}

代码示例来源:origin: apache/lens

/**
 * After test.
 *
 * @throws Exception the exception
 */
@AfterTest
public void afterTest() throws Exception {
 verifyThriftLogs();
 driver.close();
 Hive.get(hiveConf).dropDatabase(dataBase, true, true, true);
}

代码示例来源:origin: apache/lens

@AfterTest
public void tearDown() throws Exception {
 super.tearDown();
 Hive hive = Hive.get(new HiveConf());
 hive.dropDatabase(TEST_DB);
 mlClient.close();
}

相关文章

Hive类方法