Skip to content

Commit

Permalink
planner: remove the same projection when to InjectExtraProjection
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jun 21, 2024
1 parent 537e79e commit 9710119
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/planner/core/rule_inject_extra_projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,15 @@ func InjectProjBelowAgg(aggPlan base.PhysicalPlan, aggFuncs []*aggregation.AggFu
}

for i, item := range groupByItems {
if _, isCnst := item.(*expression.Constant); isCnst {
it := item
if _, isCnst := it.(*expression.Constant); isCnst {
continue
}
idx := slices.IndexFunc(projExprs, func(a expression.Expression) bool {
return a.Equal(ectx, groupByItems[i])
return a.Equal(ectx, it)
})
if idx < 0 {
projExprs = append(projExprs, item)
projExprs = append(projExprs, it)
newArg := &expression.Column{
UniqueID: aggPlan.SCtx().GetSessionVars().AllocPlanColumnID(),
RetType: item.GetType(ectx),
Expand Down

0 comments on commit 9710119

Please sign in to comment.