/** * 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; }
@Override public List<Task<? extends Serializable>> handle(Context context) throws SemanticException { DropDatabaseMessage msg = deserializer.getDropDatabaseMessage(context.dmd.getPayload()); String actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName; DropDatabaseDesc desc = new DropDatabaseDesc(actualDbName, true, context.eventOnlyReplicationSpec()); Task<? extends Serializable> dropDBTask = TaskFactory .get(new DDLWork(new HashSet<>(), new HashSet<>(), desc), context.hiveConf); context.log.info( "Added drop database task : {}:{}", dropDBTask.getId(), desc.getDatabaseName()); updatedMetadata.set(context.dmd.getEventTo().toString(), actualDbName, null, null); return Collections.singletonList(dropDBTask); } }
/** * 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; }
Database db = cntxt.getHive().getDatabase(dropDb.getDatabaseName()); if (db != null){
/** * 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; }
outputs.add(new WriteEntity(database, WriteEntity.WriteType.DDL_EXCLUSIVE)); DropDatabaseDesc dropDatabaseDesc = new DropDatabaseDesc(dbName, ifExists, ifCascade, new ReplicationSpec()); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), dropDatabaseDesc)));
/** * Drop a Database * @param db * @param dropDb * @return Always returns 0 * @throws HiveException */ private int dropDatabase(Hive db, DropDatabaseDesc dropDb) throws HiveException { try { db.dropDatabase(dropDb.getDatabaseName(), true, dropDb.getIfExists(), dropDb.isCasdade()); } catch (NoSuchObjectException ex) { throw new HiveException(ex, ErrorMsg.DATABASE_NOT_EXISTS, dropDb.getDatabaseName()); } return 0; }
Database db = cntxt.getHive().getDatabase(dropDb.getDatabaseName()); if (db != null){
outputs.add(new WriteEntity(database, WriteEntity.WriteType.DDL_EXCLUSIVE)); DropDatabaseDesc dropDatabaseDesc = new DropDatabaseDesc(dbName, ifExists, ifCascade); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), dropDatabaseDesc), conf));
Database db = cntxt.getHive().getDatabase(dropDb.getDatabaseName()); if (db != null){
private void analyzeDropDatabase(ASTNode ast) throws SemanticException { String dbName = unescapeIdentifier(ast.getChild(0).getText()); boolean ifExists = false; if (null != ast.getFirstChildWithType(TOK_IFEXISTS)) { ifExists = true; } DropDatabaseDesc dropDatabaseDesc = new DropDatabaseDesc(dbName, ifExists); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), dropDatabaseDesc), conf)); }
Database db = cntxt.getHive().getDatabase(dropDb.getDatabaseName()); if (db != null){
outputs.add(new WriteEntity(database, WriteEntity.WriteType.DDL_EXCLUSIVE)); DropDatabaseDesc dropDatabaseDesc = new DropDatabaseDesc(dbName, ifExists, ifCascade); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), dropDatabaseDesc), conf));
Database db = cntxt.getHive().getDatabase(dropDb.getDatabaseName()); if (db != null){