use of org.apache.hadoop.hive.metastore.api.WMTrigger in project hive by apache.
the class DDLSemanticAnalyzer method analyzeCreateTrigger.
private void analyzeCreateTrigger(ASTNode ast) throws SemanticException {
if (ast.getChildCount() != 4) {
throw new SemanticException("Invalid syntax for create trigger statement");
}
String rpName = unescapeIdentifier(ast.getChild(0).getText());
String triggerName = unescapeIdentifier(ast.getChild(1).getText());
String triggerExpression = buildTriggerExpression((ASTNode) ast.getChild(2));
String actionExpression = buildTriggerActionExpression((ASTNode) ast.getChild(3));
WMTrigger trigger = new WMTrigger(rpName, triggerName);
trigger.setTriggerExpression(triggerExpression);
trigger.setActionExpression(actionExpression);
CreateWMTriggerDesc desc = new CreateWMTriggerDesc(trigger);
addServiceOutput();
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
}
use of org.apache.hadoop.hive.metastore.api.WMTrigger in project hive by apache.
the class TezSessionPoolManager method updateTriggers.
public void updateTriggers(final WMFullResourcePlan appliedRp) {
if (sessionTriggerProvider != null) {
List<WMTrigger> wmTriggers = appliedRp != null ? appliedRp.getTriggers() : null;
List<Trigger> triggers = new ArrayList<>();
if (wmTriggers != null) {
for (WMTrigger wmTrigger : wmTriggers) {
if (wmTrigger.isSetIsInUnmanaged() && wmTrigger.isIsInUnmanaged()) {
triggers.add(ExecutionTrigger.fromWMTrigger(wmTrigger));
}
}
}
sessionTriggerProvider.setTriggers(Collections.unmodifiableList(triggers));
}
}
use of org.apache.hadoop.hive.metastore.api.WMTrigger in project hive by apache.
the class AbstractJdbcTriggersTest method wmTriggerFromTrigger.
WMTrigger wmTriggerFromTrigger(Trigger trigger) {
WMTrigger result = new WMTrigger("rp", trigger.getName());
result.setTriggerExpression(trigger.getExpression().toString());
result.setActionExpression(trigger.getAction().toString());
return result;
}
use of org.apache.hadoop.hive.metastore.api.WMTrigger in project hive by apache.
the class TestTriggersNoTezSessionPool method setupTriggers.
@Override
void setupTriggers(final List<Trigger> triggers) throws Exception {
WMFullResourcePlan rp = new WMFullResourcePlan(new WMResourcePlan("rp"), null);
for (Trigger trigger : triggers) {
WMTrigger wmTrigger = wmTriggerFromTrigger(trigger);
wmTrigger.setIsInUnmanaged(true);
rp.addToTriggers(wmTrigger);
}
TezSessionPoolManager.getInstance().updateTriggers(rp);
}
use of org.apache.hadoop.hive.metastore.api.WMTrigger in project hive by apache.
the class TestTriggersTezSessionPoolManager method setupTriggers.
@Override
protected void setupTriggers(final List<Trigger> triggers) throws Exception {
WMFullResourcePlan rp = new WMFullResourcePlan(new WMResourcePlan("rp"), null);
for (Trigger trigger : triggers) {
WMTrigger wmTrigger = wmTriggerFromTrigger(trigger);
wmTrigger.setIsInUnmanaged(true);
rp.addToTriggers(wmTrigger);
}
TezSessionPoolManager.getInstance().updateTriggers(rp);
}
Aggregations