本文整理了Java中org.apache.hadoop.hive.ql.metadata.Hive.alterDatabase()
方法的一些代码示例,展示了Hive.alterDatabase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hive.alterDatabase()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.metadata.Hive
类名称:Hive
方法名:alterDatabase
暂无
代码示例来源:origin: apache/hive
void updateDbLocation(Database db, Path newLocation) throws HiveException {
String msg = String.format("ALTER DATABASE %s SET LOCATION '%s'", db.getName(), newLocation);
LOG.info(msg);
db.setLocationUri(newLocation.toString());
hive.alterDatabase(db.getName(), db);
}
代码示例来源:origin: apache/hive
public static void resetDbBootstrapDumpState(Hive hiveDb, String dbName,
String uniqueKey) throws HiveException {
Database database = hiveDb.getDatabase(dbName);
if (database != null) {
Map<String, String> params = database.getParameters();
if ((params != null) && params.containsKey(uniqueKey)) {
params.remove(uniqueKey);
database.setParameters(params);
hiveDb.alterDatabase(dbName, database);
LOG.info("REPL DUMP:: Reset property for Database: {}, Property: {}", dbName, uniqueKey);
}
}
}
代码示例来源:origin: apache/hive
public static String setDbBootstrapDumpState(Hive hiveDb, String dbName) throws HiveException {
Database database = hiveDb.getDatabase(dbName);
if (database == null) {
return null;
}
Map<String, String> newParams = new HashMap<>();
String uniqueKey = BOOTSTRAP_DUMP_STATE_KEY_PREFIX + UUID.randomUUID().toString();
newParams.put(uniqueKey, ReplDumpState.ACTIVE.name());
Map<String, String> params = database.getParameters();
// if both old params are not null, merge them
if (params != null) {
params.putAll(newParams);
database.setParameters(params);
} else {
// if one of them is null, replace the old params with the new one
database.setParameters(newParams);
}
hiveDb.alterDatabase(dbName, database);
LOG.info("REPL DUMP:: Set property for Database: {}, Property: {}, Value: {}",
dbName, uniqueKey, Utils.ReplDumpState.ACTIVE.name());
return uniqueKey;
}
代码示例来源:origin: apache/hive
db.alterDatabase(database.getName(), database);
return 0;
代码示例来源:origin: apache/drill
private int alterDatabase(Hive db, AlterDatabaseDesc alterDbDesc) throws HiveException {
String dbName = alterDbDesc.getDatabaseName();
Database database = db.getDatabase(dbName);
if (database == null) {
throw new HiveException(ErrorMsg.DATABASE_NOT_EXISTS, dbName);
}
switch (alterDbDesc.getAlterType()) {
case ALTER_PROPERTY:
Map<String, String> newParams = alterDbDesc.getDatabaseProperties();
Map<String, String> params = database.getParameters();
// if both old and new params are not null, merge them
if (params != null && newParams != null) {
params.putAll(newParams);
database.setParameters(params);
} else {
// if one of them is null, replace the old params with the new one
database.setParameters(newParams);
}
break;
case ALTER_OWNER:
database.setOwnerName(alterDbDesc.getOwnerPrincipal().getName());
database.setOwnerType(alterDbDesc.getOwnerPrincipal().getType());
break;
default:
throw new AssertionError("Unsupported alter database type! : " + alterDbDesc.getAlterType());
}
db.alterDatabase(database.getName(), database);
return 0;
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
private int alterDatabase(AlterDatabaseDesc alterDbDesc) throws HiveException {
String dbName = alterDbDesc.getDatabaseName();
Database database = db.getDatabase(dbName);
Map<String, String> newParams = alterDbDesc.getDatabaseProperties();
if (database != null) {
Map<String, String> params = database.getParameters();
// if both old and new params are not null, merge them
if (params != null && newParams != null) {
params.putAll(newParams);
database.setParameters(params);
} else { // if one of them is null, replace the old params with the new one
database.setParameters(newParams);
}
db.alterDatabase(database.getName(), database);
} else {
throw new HiveException("ERROR: The database " + dbName + " does not exist.");
}
return 0;
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
private int alterDatabase(AlterDatabaseDesc alterDbDesc) throws HiveException {
String dbName = alterDbDesc.getDatabaseName();
Database database = db.getDatabase(dbName);
if (database == null) {
throw new HiveException(ErrorMsg.DATABASE_NOT_EXISTS, dbName);
}
switch (alterDbDesc.getAlterType()) {
case ALTER_PROPERTY:
Map<String, String> newParams = alterDbDesc.getDatabaseProperties();
Map<String, String> params = database.getParameters();
// if both old and new params are not null, merge them
if (params != null && newParams != null) {
params.putAll(newParams);
database.setParameters(params);
} else {
// if one of them is null, replace the old params with the new one
database.setParameters(newParams);
}
break;
case ALTER_OWNER:
database.setOwnerName(alterDbDesc.getOwnerPrincipal().getName());
database.setOwnerType(alterDbDesc.getOwnerPrincipal().getType());
break;
default:
throw new AssertionError("Unsupported alter database type! : " + alterDbDesc.getAlterType());
}
db.alterDatabase(database.getName(), database);
return 0;
}
内容来源于网络,如有侵权,请联系作者删除!