private Pair<String [], ExprNormalizer.WindowSpecReferences []> doProjectionPrephase(PlanContext context, Projection projection) throws TajoException { QueryBlock block = context.queryBlock; int finalTargetNum = projection.size(); String [] referenceNames = new String[finalTargetNum]; ExprNormalizedResult[] normalizedExprList = new ExprNormalizedResult[finalTargetNum]; List<ExprNormalizer.WindowSpecReferences> windowSpecReferencesList = new ArrayList<>(); List<Integer> targetsIds = normalize(context, projection, normalizedExprList, new Matcher() { @Override public boolean isMatch(Expr expr) { return ExprFinder.finds(expr, OpType.WindowFunction).size() == 0; } }); // Note: Why separate normalization and add(Named)Expr? // // ExprNormalizer internally makes use of the named exprs in NamedExprsManager. // If we don't separate normalization work and addExprWithName, addExprWithName will find named exprs evaluated // the same logical node. It will cause impossible evaluation in physical executors. addNamedExprs(block, referenceNames, normalizedExprList, windowSpecReferencesList, projection, targetsIds); targetsIds = normalize(context, projection, normalizedExprList, new Matcher() { @Override public boolean isMatch(Expr expr) { return ExprFinder.finds(expr, OpType.WindowFunction).size() > 0; } }); addNamedExprs(block, referenceNames, normalizedExprList, windowSpecReferencesList, projection, targetsIds); return new Pair<>(referenceNames, windowSpecReferencesList.toArray(new ExprNormalizer.WindowSpecReferences[windowSpecReferencesList.size()])); }
private Pair<String [], ExprNormalizer.WindowSpecReferences []> doProjectionPrephase(PlanContext context, Projection projection) throws TajoException { QueryBlock block = context.queryBlock; int finalTargetNum = projection.size(); String [] referenceNames = new String[finalTargetNum]; ExprNormalizedResult[] normalizedExprList = new ExprNormalizedResult[finalTargetNum]; List<ExprNormalizer.WindowSpecReferences> windowSpecReferencesList = TUtil.newList(); List<Integer> targetsIds = normalize(context, projection, normalizedExprList, new Matcher() { @Override public boolean isMatch(Expr expr) { return ExprFinder.finds(expr, OpType.WindowFunction).size() == 0; } }); // Note: Why separate normalization and add(Named)Expr? // // ExprNormalizer internally makes use of the named exprs in NamedExprsManager. // If we don't separate normalization work and addExprWithName, addExprWithName will find named exprs evaluated // the same logical node. It will cause impossible evaluation in physical executors. addNamedExprs(block, referenceNames, normalizedExprList, windowSpecReferencesList, projection, targetsIds); targetsIds = normalize(context, projection, normalizedExprList, new Matcher() { @Override public boolean isMatch(Expr expr) { return ExprFinder.finds(expr, OpType.WindowFunction).size() > 0; } }); addNamedExprs(block, referenceNames, normalizedExprList, windowSpecReferencesList, projection, targetsIds); return new Pair<String[], ExprNormalizer.WindowSpecReferences []>(referenceNames, windowSpecReferencesList.toArray(new ExprNormalizer.WindowSpecReferences[windowSpecReferencesList.size()])); }