Skip to content

Commit

Permalink
plan, executor: remvove hasAgg field. (pingcap#5265)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored and zimulala committed Nov 30, 2017
1 parent 5f46848 commit db270fc
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 11 deletions.
6 changes: 1 addition & 5 deletions executor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type HashAggExec struct {
baseExecutor

executed bool
hasGby bool
aggType plan.AggregationType
sc *stmtctx.StatementContext
AggFuncs []aggregation.Aggregation
Expand Down Expand Up @@ -74,7 +73,7 @@ func (e *HashAggExec) Next(goCtx goctx.Context) (Row, error) {
break
}
}
if (e.groupMap.Len() == 0) && !e.hasGby {
if (e.groupMap.Len() == 0) && len(e.GroupByItems) == 0 {
// If no groupby and no data, we should add an empty group.
// For example:
// "select count(c) from t;" should return one row [0]
Expand All @@ -96,9 +95,6 @@ func (e *HashAggExec) Next(goCtx goctx.Context) (Row, error) {
}

func (e *HashAggExec) getGroupKey(row Row) ([]byte, error) {
if !e.hasGby {
return []byte{}, nil
}
vals := make([]types.Datum, 0, len(e.GroupByItems))
for _, item := range e.GroupByItems {
v, err := item.Eval(row)
Expand Down
1 change: 0 additions & 1 deletion executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ func (b *executorBuilder) buildAggregation(v *plan.PhysicalAggregation) Executor
AggFuncs: v.AggFuncs,
GroupByItems: v.GroupByItems,
aggType: v.AggType,
hasGby: v.HasGby,
}
}

Expand Down
2 changes: 1 addition & 1 deletion plan/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (p *Limit) ExplainInfo() string {
// ExplainInfo implements PhysicalPlan interface.
func (p *PhysicalAggregation) ExplainInfo() string {
buffer := bytes.NewBufferString(fmt.Sprintf("type:%s", p.AggType))
if p.HasGby && len(p.GroupByItems) > 0 {
if len(p.GroupByItems) > 0 {
buffer.WriteString(fmt.Sprintf(", group by:%s",
expression.ExplainExpressionList(p.GroupByItems)))
}
Expand Down
1 change: 0 additions & 1 deletion plan/gen_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ func (p *LogicalAggregation) generatePhysicalPlans() []PhysicalPlan {
agg := PhysicalAggregation{
GroupByItems: p.GroupByItems,
AggFuncs: p.AggFuncs,
HasGby: len(p.GroupByItems) > 0,
AggType: CompleteAgg,
}.init(p.ctx)
agg.SetSchema(p.schema.Clone())
Expand Down
1 change: 0 additions & 1 deletion plan/physical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,6 @@ func (p *LogicalAggregation) getStreamAggs() []PhysicalPlan {
agg := PhysicalAggregation{
GroupByItems: p.GroupByItems,
AggFuncs: p.AggFuncs,
HasGby: len(p.GroupByItems) > 0,
AggType: StreamedAgg,
propKeys: cols,
inputCount: p.inputCount,
Expand Down
1 change: 0 additions & 1 deletion plan/physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ type PhysicalAggregation struct {
*basePlan
basePhysicalPlan

HasGby bool
AggType AggregationType
AggFuncs []aggregation.Aggregation
GroupByItems []expression.Expression
Expand Down
1 change: 0 additions & 1 deletion plan/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ func (p *PhysicalAggregation) newPartialAggregate() (partialAgg, finalAgg *Physi
finalAggFuncs[i] = fun
}
finalAgg = PhysicalAggregation{
HasGby: p.HasGby, // TODO: remove this field
AggType: FinalAgg,
AggFuncs: finalAggFuncs,
}.init(p.ctx)
Expand Down

0 comments on commit db270fc

Please sign in to comment.