Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner/core: push selection operator to mpp task #22343

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
planner/core: push selection operator to mpp task
  • Loading branch information
hanfei1991 committed Jan 11, 2021
commit fd823b5a8523b2a7b8dcfd9fb75e8a4560cf9deb
6 changes: 6 additions & 0 deletions planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func attachPlan2Task(p PhysicalPlan, t task) task {
case *rootTask:
p.SetChildren(v.p)
v.p = p
case *mppTask:
p.SetChildren(v.p)
v.p = p
}
return t
}
Expand Down Expand Up @@ -1085,6 +1088,9 @@ func (p *PhysicalUnionAll) attach2Task(tasks ...task) task {

func (sel *PhysicalSelection) attach2Task(tasks ...task) task {
sessVars := sel.ctx.GetSessionVars()
if mppTask, _ := tasks[0].(*mppTask); mppTask != nil { // always push to mpp task.
return attachPlan2Task(sel, mppTask.copy())
}
t := tasks[0].convertToRootTask(sel.ctx)
t.addCost(t.count() * sessVars.CPUFactor)
return attachPlan2Task(sel, t)
Expand Down
1 change: 1 addition & 0 deletions planner/core/testdata/integration_serial_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"explain select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k",
"explain select count(*) from fact_t join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > d1_t.value",
"explain select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > 10",
"explain select count(*) from (select case when t1.col1 is null then t2.col1 + 5 else 10 end as col1, t2.d1_k as d1_k from fact_t t1 right join fact_t t2 on t1.d1_k = t2.d1_k) fact_t join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > 5",
"explain select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col2 > 10 and fact_t.col1 > d1_t.value",
"explain select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k and d1_t.value > 10",
"explain select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k and d1_t.value > 10 and fact_t.col1 > d1_t.value",
Expand Down
25 changes: 25 additions & 0 deletions planner/core/testdata/integration_serial_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,31 @@
" └─TableFullScan_14 16.00 cop[tiflash] table:fact_t keep order:false"
]
},
{
"SQL": "explain select count(*) from (select case when t1.col1 is null then t2.col1 + 5 else 10 end as col1, t2.d1_k as d1_k from fact_t t1 right join fact_t t2 on t1.d1_k = t2.d1_k) fact_t join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > 5",
"Plan": [
"HashAgg_37 1.00 root funcs:count(Column#22)->Column#19",
"└─TableReader_39 1.00 root data:ExchangeSender_38",
" └─ExchangeSender_38 1.00 cop[tiflash] ExchangeType: PassThrough",
" └─HashAgg_15 1.00 cop[tiflash] funcs:count(1)->Column#22",
" └─HashJoin_20 204.80 cop[tiflash] inner join, equal:[eq(test.d1_t.d1_k, test.fact_t.d1_k)]",
" ├─ExchangeReceiver_24(Build) 4.00 cop[tiflash] ",
" │ └─ExchangeSender_23 4.00 cop[tiflash] ExchangeType: HashPartition, Hash Cols: test.d1_t.d1_k",
" │ └─Selection_22 4.00 cop[tiflash] not(isnull(test.d1_t.d1_k))",
" │ └─TableFullScan_21 4.00 cop[tiflash] table:d1_t keep order:false",
" └─Projection_25(Probe) 102.40 cop[tiflash] test.fact_t.d1_k",
" └─Selection_27 102.40 cop[tiflash] gt(case(isnull(test.fact_t.col1), plus(test.fact_t.col1, 5), 10), 5)",
" └─HashJoin_28 128.00 cop[tiflash] right outer join, equal:[eq(test.fact_t.d1_k, test.fact_t.d1_k)]",
" ├─ExchangeReceiver_32(Build) 16.00 cop[tiflash] ",
" │ └─ExchangeSender_31 16.00 cop[tiflash] ExchangeType: HashPartition, Hash Cols: test.fact_t.d1_k",
" │ └─Selection_30 16.00 cop[tiflash] not(isnull(test.fact_t.d1_k))",
" │ └─TableFullScan_29 16.00 cop[tiflash] table:t1 keep order:false",
" └─ExchangeReceiver_36(Probe) 16.00 cop[tiflash] ",
" └─ExchangeSender_35 16.00 cop[tiflash] ExchangeType: HashPartition, Hash Cols: test.fact_t.d1_k",
" └─Selection_34 16.00 cop[tiflash] not(isnull(test.fact_t.d1_k))",
" └─TableFullScan_33 16.00 cop[tiflash] table:t2 keep order:false"
]
},
{
"SQL": "explain select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col2 > 10 and fact_t.col1 > d1_t.value",
"Plan": [
Expand Down