use of org.apache.hadoop.hive.ql.ddl.function.create.CreateFunctionDesc in project hive by apache.
the class CreateFunctionHandler method handle.
@Override
public List<Task<?>> handle(Context context) throws SemanticException {
try {
FunctionDescBuilder builder = new FunctionDescBuilder(context);
CreateFunctionDesc descToLoad = builder.build();
this.functionName = builder.metadata.function.getFunctionName();
context.log.debug("Loading function desc : {}", descToLoad.toString());
Task<DDLWork> createTask = TaskFactory.get(new DDLWork(readEntitySet, writeEntitySet, descToLoad, true, context.getDumpDirectory(), context.getMetricCollector()), context.hiveConf);
context.log.debug("Added create function task : {}:{},{}", createTask.getId(), descToLoad.getName(), descToLoad.getClassName());
// different handlers, unless this is a common pattern that is seen, leaving this here.
if (context.dmd != null) {
updatedMetadata.set(context.dmd.getEventTo().toString(), builder.destinationDbName, null, null);
}
readEntitySet.add(toReadEntity(new Path(context.location), context.hiveConf));
if (builder.replCopyTasks.isEmpty()) {
// reply copy only happens for jars on hdfs not otherwise.
return Collections.singletonList(createTask);
} else {
/**
* This is to understand how task dependencies work.
* All root tasks are executed in parallel. For bootstrap replication there should be only one root task of creating db. Incremental can be multiple ( have to verify ).
* Task has children, which are put in queue for execution after the parent has finished execution.
* One -to- One dependency can be satisfied by adding children to a given task, do this recursively where the relation holds.
* for many to one , create a barrier task that is the child of every item in 'many' dependencies, make the 'one' dependency as child of barrier task.
* add the 'many' to parent/root tasks. The execution environment will make sure that the child barrier task will not get executed unless all parents of the barrier task are complete,
* which should only happen when the last task is finished, at which point the child of the barrier task is picked up.
*/
Task<?> barrierTask = TaskFactory.get(new DependencyCollectionWork(), context.hiveConf);
builder.replCopyTasks.forEach(t -> t.addDependentTask(barrierTask));
barrierTask.addDependentTask(createTask);
return builder.replCopyTasks;
}
} catch (Exception e) {
throw (e instanceof SemanticException) ? (SemanticException) e : new SemanticException("Error reading message members", e);
}
}
Aggregations