firstPhaseEvalNames); firstPhaseGroupBy.setTargets(firstPhaseTargets); secondPhaseGroupBy.setInSchema(PlannerUtil.targetToSchema(firstPhaseTargets));
@Override public LogicalNode visitGroupBy(ProcessorContext ctx, Stack<Expr> stack, Aggregation expr) throws TajoException { super.visitGroupBy(ctx, stack, expr); GroupbyNode node = getNodeFromExpr(ctx.planContext.getPlan(), expr); LogicalNode child = getNonRelationListExpr(ctx.planContext.getPlan(), expr.getChild()); node.setInSchema(child.getOutSchema()); return node; }
@Override public LogicalNode visitGroupBy(ProcessorContext ctx, Stack<Expr> stack, Aggregation expr) throws TajoException { super.visitGroupBy(ctx, stack, expr); GroupbyNode node = getNodeFromExpr(ctx.planContext.getPlan(), expr); LogicalNode child = getNonRelationListExpr(ctx.planContext.getPlan(), expr.getChild()); node.setInSchema(child.getOutSchema()); return node; }
@Override public LogicalNode visitGroupBy(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Aggregation expr) throws TajoException { stack.push(expr); // <--- push LogicalNode child = visit(ctx, stack, expr.getChild()); Projection projection = ctx.getQueryBlock().getSingletonExpr(OpType.Projection); int finalTargetNum = projection.getNamedExprs().size(); List<Target> targets = new ArrayList<>(); if (PlannerUtil.hasAsterisk(projection.getNamedExprs())) { projection.setNamedExprs(voidResolveAsteriskNamedExpr(ctx, projection.getNamedExprs())); } for (int i = 0; i < finalTargetNum; i++) { NamedExpr namedExpr = projection.getNamedExprs().get(i); EvalNode evalNode = annotator.createEvalNode(ctx, namedExpr.getExpr(), NameResolvingMode.SUBEXPRS_AND_RELS, true); if (namedExpr.hasAlias()) { targets.add(new Target(evalNode, namedExpr.getAlias())); } else { targets.add(new Target(evalNode, "?name_" + i)); } } stack.pop(); GroupbyNode groupByNode = ctx.getPlan().createNode(GroupbyNode.class); groupByNode.setInSchema(child.getOutSchema()); groupByNode.setOutSchema(PlannerUtil.targetToSchema(targets)); return groupByNode; }
groupbyNode.setInSchema(child.getOutSchema());
eachGroupbyNode.setAggFunctions(groupbyAggFunctions); eachGroupbyNode.setDistinct(true); eachGroupbyNode.setInSchema(groupbyNode.getInSchema()); otherGroupbyNode.setGroupingColumns(new Column[]{}); otherGroupbyNode.setAggFunctions(otherAggregationFunctionCallEvals); otherGroupbyNode.setInSchema(groupbyNode.getInSchema());
groupbyNode.setInSchema(child.getOutSchema());
node.setInSchema(child.getOutSchema()); if (node.isForDistinctBlock()) { // the grouping columns should be updated according to the schema of child node. node.setGroupingColumns(child.getOutSchema().toArray());
firstPhaseEvalNames); firstPhaseGroupBy.setTargets(firstPhaseTargets); secondPhaseGroupBy.setInSchema(PlannerUtil.targetToSchema(firstPhaseTargets));
private void insertDistinctOperator(LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode projectionNode, LogicalNode child) throws TajoException { if (projectionNode.getChild().getType() != NodeType.GROUP_BY) { Schema outSchema = projectionNode.getOutSchema(); GroupbyNode dupRemoval = plan.createNode(GroupbyNode.class); dupRemoval.setChild(child); dupRemoval.setInSchema(projectionNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(outSchema)); dupRemoval.setGroupingColumns(outSchema.toArray()); block.registerNode(dupRemoval); block.setAggregationRequire(); projectionNode.setChild(dupRemoval); projectionNode.setInSchema(dupRemoval.getOutSchema()); } }
@Override public LogicalNode visitGroupBy(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Aggregation expr) throws TajoException { stack.push(expr); // <--- push LogicalNode child = visit(ctx, stack, expr.getChild()); Projection projection = ctx.getQueryBlock().getSingletonExpr(OpType.Projection); int finalTargetNum = projection.getNamedExprs().length; Target [] targets = new Target[finalTargetNum]; if (PlannerUtil.hasAsterisk(projection.getNamedExprs())) { projection.setNamedExprs(voidResolveAsteriskNamedExpr(ctx, projection.getNamedExprs())); } for (int i = 0; i < finalTargetNum; i++) { NamedExpr namedExpr = projection.getNamedExprs()[i]; EvalNode evalNode = annotator.createEvalNode(ctx, namedExpr.getExpr(), NameResolvingMode.SUBEXPRS_AND_RELS, true); if (namedExpr.hasAlias()) { targets[i] = new Target(evalNode, namedExpr.getAlias()); } else { targets[i] = new Target(evalNode, "?name_" + i); } } stack.pop(); GroupbyNode groupByNode = ctx.getPlan().createNode(GroupbyNode.class); groupByNode.setInSchema(child.getOutSchema()); groupByNode.setOutSchema(PlannerUtil.targetToSchema(targets)); return groupByNode; }
private void insertDistinctOperator(LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode projectionNode, LogicalNode child) throws TajoException { if (projectionNode.getChild().getType() != NodeType.GROUP_BY) { Schema outSchema = projectionNode.getOutSchema(); GroupbyNode dupRemoval = plan.createNode(GroupbyNode.class); dupRemoval.setChild(child); dupRemoval.setInSchema(projectionNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(outSchema)); dupRemoval.setGroupingColumns(outSchema.toArray()); block.registerNode(dupRemoval); block.setAggregationRequire(); projectionNode.setChild(dupRemoval); projectionNode.setInSchema(dupRemoval.getOutSchema()); } }
private static GroupbyNode convertGroupby(OverridableConf context, EvalContext evalContext, Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.GroupbyNode groupbyProto = protoNode.getGroupby(); GroupbyNode groupby = new GroupbyNode(protoNode.getNodeId()); groupby.setChild(nodeMap.get(groupbyProto.getChildSeq())); groupby.setDistinct(groupbyProto.getDistinct()); if (groupbyProto.getGroupingKeysCount() > 0) { groupby.setGroupingColumns(convertColumns(groupbyProto.getGroupingKeysList())); } if (groupbyProto.getAggFunctionsCount() > 0) { groupby.setAggFunctions(convertAggFuncCallEvals(context, evalContext, groupbyProto.getAggFunctionsList())); } if (groupbyProto.getTargetsCount() > 0) { groupby.setTargets(convertTargets(context, evalContext, groupbyProto.getTargetsList())); } groupby.setInSchema(convertSchema(protoNode.getInSchema())); groupby.setOutSchema(convertSchema(protoNode.getOutSchema())); return groupby; }
private static GroupbyNode convertGroupby(OverridableConf context, EvalContext evalContext, Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.GroupbyNode groupbyProto = protoNode.getGroupby(); GroupbyNode groupby = new GroupbyNode(protoNode.getNodeId()); groupby.setChild(nodeMap.get(groupbyProto.getChildSeq())); groupby.setDistinct(groupbyProto.getDistinct()); if (groupbyProto.getGroupingKeysCount() > 0) { groupby.setGroupingColumns(convertColumns(groupbyProto.getGroupingKeysList())); } if (groupbyProto.getAggFunctionsCount() > 0) { groupby.setAggFunctions(convertAggFuncCallEvals(context, evalContext, groupbyProto.getAggFunctionsList())); } if (groupbyProto.getTargetsCount() > 0) { groupby.setTargets(convertTargets(context, evalContext, groupbyProto.getTargetsList())); } groupby.setInSchema(convertSchema(protoNode.getInSchema())); groupby.setOutSchema(convertSchema(protoNode.getOutSchema())); return groupby; }
private ExecutionBlock buildTwoPhaseGroupby(MasterPlan masterPlan, ExecutionBlock latestBlock, GroupbyNode firstPhaseGroupby, GroupbyNode secondPhaseGroupby) throws TajoException { ExecutionBlock childBlock = latestBlock; childBlock.setPlan(firstPhaseGroupby); ExecutionBlock currentBlock = masterPlan.newExecutionBlock(); DataChannel channel; if (firstPhaseGroupby.isEmptyGrouping()) { channel = new DataChannel(childBlock, currentBlock, HASH_SHUFFLE, 1); channel.setShuffleKeys(firstPhaseGroupby.getGroupingColumns()); } else { channel = new DataChannel(childBlock, currentBlock, HASH_SHUFFLE, 32); channel.setShuffleKeys(firstPhaseGroupby.getGroupingColumns()); } channel.setSchema(firstPhaseGroupby.getOutSchema()); channel.setDataFormat(dataFormat); ScanNode scanNode = buildInputExecutor(masterPlan.getLogicalPlan(), channel); secondPhaseGroupby.setChild(scanNode); secondPhaseGroupby.setInSchema(scanNode.getOutSchema()); currentBlock.setPlan(secondPhaseGroupby); masterPlan.addConnect(channel); return currentBlock; }
private ExecutionBlock buildTwoPhaseGroupby(MasterPlan masterPlan, ExecutionBlock latestBlock, GroupbyNode firstPhaseGroupby, GroupbyNode secondPhaseGroupby) throws TajoException { ExecutionBlock childBlock = latestBlock; childBlock.setPlan(firstPhaseGroupby); ExecutionBlock currentBlock = masterPlan.newExecutionBlock(); DataChannel channel; if (firstPhaseGroupby.isEmptyGrouping()) { channel = new DataChannel(childBlock, currentBlock, HASH_SHUFFLE, 1); channel.setShuffleKeys(firstPhaseGroupby.getGroupingColumns()); } else { channel = new DataChannel(childBlock, currentBlock, HASH_SHUFFLE, 32); channel.setShuffleKeys(firstPhaseGroupby.getGroupingColumns()); } channel.setSchema(firstPhaseGroupby.getOutSchema()); channel.setDataFormat(dataFormat); ScanNode scanNode = buildInputExecutor(masterPlan.getLogicalPlan(), channel); secondPhaseGroupby.setChild(scanNode); secondPhaseGroupby.setInSchema(scanNode.getOutSchema()); currentBlock.setPlan(secondPhaseGroupby); masterPlan.addConnect(channel); return currentBlock; }
dupRemoval.setForDistinctBlock(); dupRemoval.setChild(sortNode.getChild()); dupRemoval.setInSchema(sortNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(sortNode.getInSchema())); dupRemoval.setGroupingColumns(sortNode.getInSchema().toArray()); dupRemoval.setForDistinctBlock(); dupRemoval.setChild(child); dupRemoval.setInSchema(projectionNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(outSchema)); dupRemoval.setGroupingColumns(outSchema.toArray());
dupRemoval.setForDistinctBlock(); dupRemoval.setChild(sortNode.getChild()); dupRemoval.setInSchema(sortNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(sortNode.getInSchema())); dupRemoval.setGroupingColumns(sortNode.getInSchema().toArray()); dupRemoval.setForDistinctBlock(); dupRemoval.setChild(child); dupRemoval.setInSchema(projectionNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(outSchema)); dupRemoval.setGroupingColumns(outSchema.toArray());
setOpGroupbyNode.setInSchema(setOpSchema); setOpGroupbyNode.setGroupingColumns(setOpSchema.toArray()); setOpGroupbyNode.setTargets(setOpTarget);
setOpGroupbyNode.setInSchema(setOpSchema); setOpGroupbyNode.setGroupingColumns(setOpSchema.toArray()); setOpGroupbyNode.setTargets(setOpTarget);