Skip to content

Commit

Permalink
more clear fix and remove unused changes
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Dec 13, 2018
1 parent ff45b3f commit 16196a1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
8 changes: 2 additions & 6 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}
}
Expand Down
14 changes: 11 additions & 3 deletions planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 2 additions & 4 deletions planner/core/exhaust_physical_plans_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: "[]",
Expand Down Expand Up @@ -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)]",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 16196a1

Please sign in to comment.