/* * add any input columns referenced in WindowFn args or expressions. */ private ArrayList<String> prunedColumnsList( List<String> prunedCols, WindowTableFunctionDef tDef) { // we create a copy of prunedCols to create a list of pruned columns for PTFOperator ArrayList<String> mergedColList = new ArrayList<String>(prunedCols); if (tDef.getWindowFunctions() != null) { for (WindowFunctionDef wDef : tDef.getWindowFunctions()) { if (wDef.getArgs() == null) { continue; } for (PTFExpressionDef arg : wDef.getArgs()) { ExprNodeDesc exprNode = arg.getExprNode(); Utilities.mergeUniqElems(mergedColList, exprNode.getCols()); } } } if (tDef.getPartition() != null) { for (PTFExpressionDef col : tDef.getPartition().getExpressions()) { ExprNodeDesc exprNode = col.getExprNode(); Utilities.mergeUniqElems(mergedColList, exprNode.getCols()); } } if (tDef.getOrder() != null) { for (PTFExpressionDef col : tDef.getOrder().getExpressions()) { ExprNodeDesc exprNode = col.getExprNode(); Utilities.mergeUniqElems(mergedColList, exprNode.getCols()); } } return mergedColList; }
/* * from the prunedCols list filter out columns that refer to WindowFns or WindowExprs * the returned list is set as the prunedList needed by the PTFOp. */ private ArrayList<String> prunedInputList( List<String> prunedCols, WindowTableFunctionDef tDef) { ArrayList<String> prunedInputCols = new ArrayList<String>(); StructObjectInspector OI = tDef.getInput().getOutputShape().getOI(); for (StructField f : OI.getAllStructFieldRefs()) { String fName = f.getFieldName(); if (prunedCols.contains(fName)) { prunedInputCols.add(fName); } } return prunedInputCols; }