public static class ColumnPrunerPTFProc implements NodeProcessor {
public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx ctx,
Object... nodeOutputs) throws SemanticException {
ColumnPrunerProcCtx cppCtx = (ColumnPrunerProcCtx) ctx;
PTFOperator op = (PTFOperator) nd;
PTFDesc conf = op.getConf();
//Since we cannot know what columns will be needed by a PTF chain,
//we do not prune columns on PTFOperator for PTF chains.
if (!conf.forWindowing()) {
Operator<? extends OperatorDesc> parent = op.getParentOperators().get(0);
RowResolver parentRR = cppCtx.getParseContext().getOpParseCtx().get(parent).getRowResolver();
List<ColumnInfo> sig = parentRR.getRowSchema().getSignature();
List<String> colList = new ArrayList<String>();
for(ColumnInfo cI : sig) {
colList.add(cI.getInternalName());
}
cppCtx.getPrunedColLists().put(op, colList);
return null;
}
WindowTableFunctionDef def = (WindowTableFunctionDef) conf.getFuncDef();
ArrayList<ColumnInfo> sig = new ArrayList<ColumnInfo>();
List<String> prunedCols = cppCtx.getPrunedColList(op.getChildOperators().get(0));
//we create a copy of prunedCols to create a list of pruned columns for PTFOperator
prunedCols = new ArrayList<String>(prunedCols);
prunedColumnsList(prunedCols, def);
RowResolver oldRR = cppCtx.getOpToParseCtxMap().get(op).getRowResolver();
RowResolver newRR = buildPrunedRR(prunedCols, oldRR, sig);
cppCtx.getPrunedColLists().put(op, prunedInputList(prunedCols, def));
cppCtx.getOpToParseCtxMap().get(op).setRowResolver(newRR);
op.getSchema().setSignature(sig);
return null;
}