Skip to content

Commit

Permalink
planner/core: fix bug that injected proj get wrong index. (#25336)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored Jun 11, 2021
1 parent 9505b4b commit b76d467
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions executor/tiflash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,17 @@ func (s *tiflashTestSuite) TestMppUnionAll(c *C) {
tk.MustQuery("select count(*) from (select * from x1 union all select * from x2 union all select * from x3) x join (select * from x1 union all select * from x2 union all select * from x3) y on x.a = y.b").Check(testkit.Rows("29"))
failpoint.Disable("github.com/pingcap/tidb/executor/checkTotalMPPTasks")

tk.MustExec("drop table if exists x4")
tk.MustExec("create table x4(a int not null, b int not null);")
tk.MustExec("alter table x4 set tiflash replica 1")
tb = testGetTableByName(c, tk.Se, "test", "x4")
err = domain.GetDomain(tk.Se).DDL().UpdateTableReplicaInfo(tk.Se, tb.Meta().ID, true)
c.Assert(err, IsNil)

tk.MustExec("set @@tidb_enforce_mpp=1")
tk.MustExec("insert into x4 values (2, 2), (2, 3)")
tk.MustQuery("(select * from x1 union all select * from x4) order by a, b").Check(testkit.Rows("1 1", "2 2", "2 2", "2 3", "3 3", "4 4"))

}

func (s *tiflashTestSuite) TestMppApply(c *C) {
Expand Down
1 change: 1 addition & 0 deletions planner/core/rule_inject_extra_projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func injectProjBelowUnion(un *PhysicalUnionAll) *PhysicalUnionAll {
for i, dstCol := range un.schema.Columns {
dstType := dstCol.RetType
srcCol := ch.Schema().Columns[i]
srcCol.Index = i
srcType := srcCol.RetType
if !srcType.Equal(dstType) || !(mysql.HasNotNullFlag(dstType.Flag) == mysql.HasNotNullFlag(srcType.Flag)) {
exprs[i] = expression.BuildCastFunction4Union(un.ctx, srcCol, dstType)
Expand Down

0 comments on commit b76d467

Please sign in to comment.