From df53bfd52e4dd9cddbb7523974640a51ed3f992c Mon Sep 17 00:00:00 2001 From: longfang Date: Thu, 26 Dec 2019 20:51:29 -0800 Subject: [PATCH] Address comments. --- .../testdata/transformation_rules_suite_out.json | 2 +- planner/cascades/transformation_rules.go | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/planner/cascades/testdata/transformation_rules_suite_out.json b/planner/cascades/testdata/transformation_rules_suite_out.json index c3d0e8ea5a093..374a18735f04b 100644 --- a/planner/cascades/testdata/transformation_rules_suite_out.json +++ b/planner/cascades/testdata/transformation_rules_suite_out.json @@ -351,7 +351,7 @@ "Group#0 Schema:[test.t.b]", " Projection_2 input:[Group#1], test.t.b", "Group#1 Schema:[test.t.b]", - " Limit_6 input:[Group#2], offset:0, count:2", + " Limit_3 input:[Group#2], offset:0, count:2", "Group#2 Schema:[test.t.b]", " TiKVSingleGather_5 input:[Group#3], table:t", "Group#3 Schema:[test.t.b]", diff --git a/planner/cascades/transformation_rules.go b/planner/cascades/transformation_rules.go index f038ea5ffcc88..5581a48f1aea6 100644 --- a/planner/cascades/transformation_rules.go +++ b/planner/cascades/transformation_rules.go @@ -671,7 +671,8 @@ type PushLimitDownProjection struct { baseRule } -// NewRulePushLimitDownProjection creates a new Transformation. The pattern of this rule is `Limit->Projection->X` to `Projection->Limit->X`. +// NewRulePushLimitDownProjection creates a new Transformation. +// The pattern of this rule is `Limit->Projection->X` to `Projection->Limit->X`. func NewRulePushLimitDownProjection() Transformation { rule := &PushLimitDownProjection{} rule.pattern = memo.BuildPattern( @@ -700,13 +701,8 @@ func (r *PushLimitDownProjection) OnTransform(old *memo.ExprIter) (newExprs []*m proj := old.Children[0].GetExpr().ExprNode.(*plannercore.LogicalProjection) childGroup := old.Children[0].GetExpr().Children[0] - newLimit := plannercore.LogicalLimit{ - Offset: limit.Offset, - Count: limit.Count, - }.Init(limit.SCtx(), limit.SelectBlockOffset()) - projExpr := memo.NewGroupExpr(proj) - limitExpr := memo.NewGroupExpr(newLimit) + limitExpr := memo.NewGroupExpr(limit) limitExpr.SetChildren(childGroup) limitGroup := memo.NewGroupWithSchema(limitExpr, childGroup.Prop.Schema) projExpr.SetChildren(limitGroup)