List<Target> firstPhaseTargets = ProjectionPushDownRule.buildGroupByTarget(firstPhaseGroupBy, null, firstPhaseEvalNames); firstPhaseGroupBy.setTargets(firstPhaseTargets); secondPhaseGroupBy.setInSchema(PlannerUtil.targetToSchema(firstPhaseTargets));
eachGroupbyNode.setTargets(targets); eachGroupbyNode.setAggFunctions(groupbyAggFunctions); eachGroupbyNode.setDistinct(true); otherGroupbyNode.setTargets(targets); otherGroupbyNode.setGroupingColumns(originalGroupingColumns.toArray(new Column[originalGroupingColumns.size()])); otherGroupbyNode.setAggFunctions(otherAggregationFunctionCallEvals);
Target [] targets = ProjectionPushDownRule.buildGroupByTarget(groupbyNode, null, aggEvalNames.toArray(new String[aggEvalNames.size()])); groupbyNode.setTargets(targets);
eachGroupbyNode.setTargets(targets); eachGroupbyNode.setAggFunctions(groupbyAggFunctions); eachGroupbyNode.setDistinct(true); baseGroupByTargets.addAll(otherAggregationFunctionTargets); otherGroupbyNode.setTargets(targets); otherGroupbyNode.setGroupingColumns(new Column[]{}); otherGroupbyNode.setAggFunctions(otherAggregationFunctionCallEvals);
List<Target> targets = ProjectionPushDownRule.buildGroupByTarget(groupbyNode, null, aggEvalNames.toArray(new String[aggEvalNames.size()])); groupbyNode.setTargets(targets);
if (node.isForDistinctBlock()) { // the grouping columns should be updated according to the schema of child node. node.setGroupingColumns(child.getOutSchema().toArray()); node.setTargets(PlannerUtil.schemaToTargets(child.getOutSchema())); node.setTargets(finalTargets);
targets[targetIdx++] = eachAggFunctionTarget; eachGroupbyNode.setTargets(targets); eachGroupbyNode.setAggFunctions(groupbyAggFunctions.toArray(new AggregationFunctionCallEval[]{})); eachGroupbyNode.setDistinct(true); otherGroupbyNode.setTargets(targets); otherGroupbyNode.setGroupingColumns(originalGroupingColumns.toArray(new Column[]{})); otherGroupbyNode.setAggFunctions(otherAggregationFunctionCallEvals.toArray(new AggregationFunctionCallEval[]{}));
groupingNode.setTargets(targets); block.unsetAggregationRequire();
firstStageGroupby.setGroupingColumns(TUtil.toArray(firstStageGroupingColumns, Column.class)); firstStageGroupby.setAggFunctions(firstStageAggFunctions); firstStageGroupby.setTargets(firstStageTargets); firstStageGroupby.setChild(groupbyNode.getChild()); firstStageGroupby.setInSchema(groupbyNode.getInSchema()); secondPhaseGroupby.setGroupingColumns(originalGroupingColumns); secondPhaseGroupby.setAggFunctions(secondPhaseEvalNodes); secondPhaseGroupby.setTargets(groupbyNode.getTargets());
firstStageGroupby.setGroupingColumns(TUtil.toArray(firstStageGroupingColumns, Column.class)); firstStageGroupby.setAggFunctions(TUtil.toArray(firstStageAggFunctions, AggregationFunctionCallEval.class)); firstStageGroupby.setTargets(firstStageTargets); firstStageGroupby.setChild(groupbyNode.getChild()); firstStageGroupby.setInSchema(groupbyNode.getInSchema()); secondPhaseGroupby.setGroupingColumns(originalGroupingColumns); secondPhaseGroupby.setAggFunctions(TUtil.toArray(secondPhaseEvalNodes, AggregationFunctionCallEval.class)); secondPhaseGroupby.setTargets(groupbyNode.getTargets());
if (node.isForDistinctBlock()) { // the grouping columns should be updated according to the schema of child node. node.setGroupingColumns(child.getOutSchema().toArray()); node.setTargets(PlannerUtil.schemaToTargets(child.getOutSchema())); node.setTargets(finalTargets);
Target [] firstPhaseTargets = ProjectionPushDownRule.buildGroupByTarget(firstPhaseGroupBy, null, 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()); } }
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; }
dupRemoval.setChild(sortNode.getChild()); dupRemoval.setInSchema(sortNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(sortNode.getInSchema())); dupRemoval.setGroupingColumns(sortNode.getInSchema().toArray()); dupRemoval.setChild(child); dupRemoval.setInSchema(projectionNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(outSchema)); dupRemoval.setGroupingColumns(outSchema.toArray());
dupRemoval.setChild(sortNode.getChild()); dupRemoval.setInSchema(sortNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(sortNode.getInSchema())); dupRemoval.setGroupingColumns(sortNode.getInSchema().toArray()); 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.setChild(setOpTableSubQueryNode); currentBlock.registerNode(setOpGroupbyNode);
setOpGroupbyNode.setInSchema(setOpSchema); setOpGroupbyNode.setGroupingColumns(setOpSchema.toArray()); setOpGroupbyNode.setTargets(setOpTarget); setOpGroupbyNode.setChild(setOpTableSubQueryNode); currentBlock.registerNode(setOpGroupbyNode);