throw new IOException("Invalid alias: " + id);
}
try {
Graph g = getClonedGraph();
LogicalPlan lp = g.getPlan(id);
// MRCompiler needs a store to be the leaf - hence
// add a store to the plan to explain
// figure out the leaf to which the store needs to be added
List<LogicalOperator> leaves = lp.getLeaves();
LogicalOperator leaf = null;
if(leaves.size() == 1) {
leaf = leaves.get(0);
} else {
for (Iterator<LogicalOperator> it = leaves.iterator(); it.hasNext();) {
LogicalOperator leafOp = it.next();
if(leafOp.getAlias().equals(id))
leaf = leafOp;
}
}
LogicalPlan unCompiledstorePlan = QueryParser.generateStorePlan(
scope, lp, filename, func, leaf, leaf.getAlias(),
pigContext);
LogicalPlan storePlan = compileLp(unCompiledstorePlan, g, true);
return executeCompiledLogicalPlan(storePlan);
} catch (PigException e) {
int errCode = 1002;
String msg = "Unable to store alias " + id;