From 16196a18c981212ffe2be7fe128aedc959e70902 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Thu, 13 Dec 2018 18:47:40 +0800 Subject: [PATCH] more clear fix and remove unused changes --- executor/builder.go | 8 ++------ planner/core/exhaust_physical_plans.go | 14 +++++++++++--- planner/core/exhaust_physical_plans_test.go | 6 ++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/executor/builder.go b/executor/builder.go index 79f4ad520b52c..753f2e987058f 100644 --- a/executor/builder.go +++ b/executor/builder.go @@ -1086,12 +1086,8 @@ func (b *executorBuilder) buildHashAgg(v *plannercore.PhysicalHashAgg) Executor e.FinalAggFuncs = append(e.FinalAggFuncs, finalAggFunc) if partialAggDesc.Name == ast.AggFuncGroupConcat { // For group_concat, finalAggFunc and partialAggFunc need shared `truncate` flag to do duplicate. - finalAggFunc.(interface { - SetTruncated(t *int32) - }).SetTruncated( - partialAggFunc.(interface { - GetTruncated() *int32 - }).GetTruncated(), + finalAggFunc.(interface{ SetTruncated(t *int32) }).SetTruncated( + partialAggFunc.(interface{ GetTruncated() *int32 }).GetTruncated(), ) } } diff --git a/planner/core/exhaust_physical_plans.go b/planner/core/exhaust_physical_plans.go index a1bb8aa8b5e06..4747a2436d191 100644 --- a/planner/core/exhaust_physical_plans.go +++ b/planner/core/exhaust_physical_plans.go @@ -636,7 +636,6 @@ func (cwc *ColWithCompareOps) resolveIndices(schema *expression.Schema) { func (cwc *ColWithCompareOps) String() string { buffer := bytes.NewBufferString("") - log.Warnf("%v, %v, %v", cwc.targetCol, cwc.OpType, cwc.opArg) for i := range cwc.OpType { buffer.WriteString(fmt.Sprintf("%v(%v, %v)", cwc.OpType[i], cwc.targetCol, cwc.opArg[i])) if i < len(cwc.OpType)-1 { @@ -761,8 +760,17 @@ loopOtherConds: remained = append(remained, colAccesses...) } accesses = append(accesses, colAccesses...) - nextColRange, err := ranger.BuildColumnRange(colAccesses, p.ctx.GetSessionVars().StmtCtx, nextCol.RetType, colLengths[nextColPos]) - ranges, err := p.buildTemplateRange(idxOff2keyOff, matchedKeyCnt, notKeyEqAndIn, nextColRange, false) + var ranges, nextColRange []*ranger.Range + var err error + if len(colAccesses) > 0 { + nextColRange, err = ranger.BuildColumnRange(colAccesses, p.ctx.GetSessionVars().StmtCtx, nextCol.RetType, colLengths[nextColPos]) + if err != nil { + return nil, nil, nil, nil, nil, err + } + ranges, err = p.buildTemplateRange(idxOff2keyOff, matchedKeyCnt, notKeyEqAndIn, nextColRange, false) + } else { + ranges, err = p.buildTemplateRange(idxOff2keyOff, matchedKeyCnt, notKeyEqAndIn, nil, false) + } if err != nil { return nil, nil, nil, nil, nil, err } diff --git a/planner/core/exhaust_physical_plans_test.go b/planner/core/exhaust_physical_plans_test.go index 2fd66cdc937e7..952900a006be5 100644 --- a/planner/core/exhaust_physical_plans_test.go +++ b/planner/core/exhaust_physical_plans_test.go @@ -22,7 +22,6 @@ import ( "github.com/pingcap/parser/mysql" "github.com/pingcap/tidb/expression" "github.com/pingcap/tidb/types" - "github.com/sirupsen/logrus" ) func (s *testUnitTestSuit) rewriteSimpleExpr(str string, schema *expression.Schema) ([]expression.Expression, error) { @@ -147,7 +146,7 @@ func (s *testUnitTestSuit) TestIndexJoinAnalyzeLookUpFilters(c *C) { innerKeys: []*expression.Column{dsSchema.Columns[1]}, pushedDownConds: "a = 1", otherConds: "", - ranges: "[[1 NULL NULL,1 NULL +inf]]", + ranges: "[[1 NULL,1 NULL]]", idxOff2KeyOff: "[-1 0 -1 -1]", accesses: "[eq(test.t.a, 1)]", remained: "[]", @@ -191,7 +190,7 @@ func (s *testUnitTestSuit) TestIndexJoinAnalyzeLookUpFilters(c *C) { innerKeys: []*expression.Column{dsSchema.Columns[1]}, pushedDownConds: "a in (1, 2, 3) and c in ('a', 'b', 'c')", otherConds: "", - ranges: "[[1 NULL \"a\" NULL,1 NULL \"a\" +inf] [2 NULL \"a\" NULL,2 NULL \"a\" +inf] [3 NULL \"a\" NULL,3 NULL \"a\" +inf] [1 NULL \"b\" NULL,1 NULL \"b\" +inf] [2 NULL \"b\" NULL,2 NULL \"b\" +inf] [3 NULL \"b\" NULL,3 NULL \"b\" +inf] [1 NULL \"c\" NULL,1 NULL \"c\" +inf] [2 NULL \"c\" NULL,2 NULL \"c\" +inf] [3 NULL \"c\" NULL,3 NULL \"c\" +inf]]", + ranges: "[[1 NULL \"a\",1 NULL \"a\"] [2 NULL \"a\",2 NULL \"a\"] [3 NULL \"a\",3 NULL \"a\"] [1 NULL \"b\",1 NULL \"b\"] [2 NULL \"b\",2 NULL \"b\"] [3 NULL \"b\",3 NULL \"b\"] [1 NULL \"c\",1 NULL \"c\"] [2 NULL \"c\",2 NULL \"c\"] [3 NULL \"c\",3 NULL \"c\"]]", idxOff2KeyOff: "[-1 0 -1 -1]", accesses: "[in(test.t.a, 1, 2, 3) in(test.t.c, a, b, c)]", remained: "[in(test.t.c, a, b, c)]", @@ -227,7 +226,6 @@ func (s *testUnitTestSuit) TestIndexJoinAnalyzeLookUpFilters(c *C) { others, err := s.rewriteSimpleExpr(tt.otherConds, joinNode.schema) c.Assert(err, IsNil) joinNode.OtherConditions = others - logrus.Warnf("others: %v", joinNode.OtherConditions) ranges, idxOff2KeyOff, accesses, remained, compareFilters, err := joinNode.analyzeLookUpFilters(idxInfo, dataSourceNode, tt.innerKeys) c.Assert(err, IsNil) c.Assert(fmt.Sprintf("%v", ranges), Equals, tt.ranges)