use of org.apache.hadoop.hive.metastore.api.WMNullablePool in project hive by apache.
the class DDLSemanticAnalyzer method analyzeAlterPool.
private void analyzeAlterPool(ASTNode ast) throws SemanticException {
if (ast.getChildCount() < 3) {
throw new SemanticException("Invalid syntax for alter pool: " + ast.toStringTree());
}
String rpName = unescapeIdentifier(ast.getChild(0).getText());
Tree poolTarget = ast.getChild(1);
boolean isUnmanagedPool = false;
String poolPath = null;
if (poolTarget.getType() == HiveParser.TOK_UNMANAGED) {
isUnmanagedPool = true;
} else {
poolPath = poolPath(ast.getChild(1));
}
WMNullablePool poolChanges = null;
boolean hasTrigger = false;
for (int i = 2; i < ast.getChildCount(); ++i) {
Tree child = ast.getChild(i);
if (child.getChildCount() != 1) {
throw new SemanticException("Invalid syntax in alter pool expected parameter.");
}
Tree param = child.getChild(0);
if (child.getType() == HiveParser.TOK_ADD_TRIGGER || child.getType() == HiveParser.TOK_DROP_TRIGGER) {
hasTrigger = true;
boolean drop = child.getType() == HiveParser.TOK_DROP_TRIGGER;
String triggerName = unescapeIdentifier(param.getText());
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), new CreateOrDropTriggerToPoolMappingDesc(rpName, triggerName, poolPath, drop, isUnmanagedPool))));
} else {
if (isUnmanagedPool) {
throw new SemanticException("Cannot alter the unmanaged pool");
}
if (poolChanges == null) {
poolChanges = new WMNullablePool(rpName, null);
}
switch(child.getType()) {
case HiveParser.TOK_ALLOC_FRACTION:
poolChanges.setAllocFraction(Double.parseDouble(param.getText()));
break;
case HiveParser.TOK_QUERY_PARALLELISM:
poolChanges.setQueryParallelism(Integer.parseInt(param.getText()));
break;
case HiveParser.TOK_SCHEDULING_POLICY:
poolChanges.setIsSetSchedulingPolicy(true);
if (param.getType() != HiveParser.TOK_NULL) {
poolChanges.setSchedulingPolicy(PlanUtils.stripQuotes(param.getText()));
}
break;
case HiveParser.TOK_PATH:
poolChanges.setPoolPath(poolPath(param));
break;
default:
throw new SemanticException("Incorrect alter syntax: " + child.toStringTree());
}
}
}
if (poolChanges != null || hasTrigger) {
addServiceOutput();
}
if (poolChanges != null) {
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), new CreateOrAlterWMPoolDesc(poolChanges, poolPath, true))));
}
}
Aggregations