Skip to content

Commit

Permalink
planner: add missing exchange between hash-partition agg and single-p…
Browse files Browse the repository at this point in the history
…artition window (#43981) (#44068)

close #43922
  • Loading branch information
ti-chi-bot committed May 24, 2023
1 parent 833ba03 commit 5ebdb66
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
2 changes: 2 additions & 0 deletions planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,8 @@ func (la *LogicalAggregation) tryToGetMppHashAggs(prop *property.PhysicalPropert
// do not satisfy the property of its parent, so return empty
return nil
}
} else if prop.MPPPartitionTp != property.AnyType {
return nil
}
// TODO: permute various partition columns from group-by columns
// 1-phase agg
Expand Down
3 changes: 2 additions & 1 deletion planner/core/testdata/window_push_down_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"explain select *, rank() over () FROM (select *, row_number() over () a from employee) tmp -- 6. multi window from sub query",
"explain select *, rank() over (partition by deptid) FROM (select *, row_number() over () a from employee) tmp -- 6.1 multi window from sub query",
// "explain select *, max(salary) over (), max(salary) over (partition by deptid order by salary), row_number() over (partition by deptid order by salary), max(salary) over (partition by deptid order by empid), row_number() over (partition by deptid order by empid), count(empid) over (partition by salary order by deptid) from employee; -- 7. complex",
"explain select *, sum(a) over (partition by deptid) FROM (select *, row_number() over (order by md5(deptid)) a from employee) tmp; -- 8. some scalar function not supported."
"explain select *, sum(a) over (partition by deptid) FROM (select *, row_number() over (order by md5(deptid)) a from employee) tmp; -- 8. some scalar function not supported.",
"explain select deptid, row_number() OVER() from (select deptid from employee group by deptid) t;"
]
},
{
Expand Down
34 changes: 26 additions & 8 deletions planner/core/testdata/window_push_down_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@
"Scalar function 'md5'(signature: MD5, return type: var_string(32)) is not supported to push down to tiflash now.",
"MPP mode may be blocked because window function `sum` is not supported now."
]
},
{
"SQL": "explain select deptid, row_number() OVER() from (select deptid from employee group by deptid) t;",
"Plan": [
"TableReader_77 8000.00 root data:ExchangeSender_76",
"└─ExchangeSender_76 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Window_75 8000.00 mpp[tiflash] row_number()->Column#6 over(rows between current row and current row)",
" └─ExchangeReceiver_19 8000.00 mpp[tiflash] ",
" └─ExchangeSender_18 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection_17 8000.00 mpp[tiflash] test.employee.deptid",
" └─HashAgg_12 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:firstrow(test.employee.deptid)->test.employee.deptid",
" └─ExchangeReceiver_16 10000.00 mpp[tiflash] ",
" └─ExchangeSender_15 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary]",
" └─TableFullScan_14 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo"
],
"Warn": null
}
]
},
Expand Down Expand Up @@ -337,14 +353,16 @@
{
"SQL": "explain select *, row_number() over () from (select count(empid) from employee group by deptid) t",
"Plan": [
"TableReader_84 8000.00 root data:ExchangeSender_83",
"└─ExchangeSender_83 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Window_82 8000.00 mpp[tiflash] row_number()->Column#7 over(rows between current row and current row)",
" └─Projection_19 8000.00 mpp[tiflash] Column#5",
" └─HashAgg_12 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:count(test.employee.empid)->Column#5",
" └─ExchangeReceiver_18 10000.00 mpp[tiflash] ",
" └─ExchangeSender_17 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary]",
" └─TableFullScan_16 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo"
"TableReader_77 8000.00 root data:ExchangeSender_76",
"└─ExchangeSender_76 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Window_75 8000.00 mpp[tiflash] row_number()->Column#7 over(rows between current row and current row)",
" └─ExchangeReceiver_19 8000.00 mpp[tiflash] ",
" └─ExchangeSender_18 8000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection_17 8000.00 mpp[tiflash] Column#5",
" └─HashAgg_12 8000.00 mpp[tiflash] group by:test.employee.deptid, funcs:count(test.employee.empid)->Column#5",
" └─ExchangeReceiver_16 10000.00 mpp[tiflash] ",
" └─ExchangeSender_15 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.employee.deptid, collate: binary]",
" └─TableFullScan_14 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo"
],
"Warn": null
},
Expand Down

0 comments on commit 5ebdb66

Please sign in to comment.