planner: enforce projection push down (#25450)

This commit is contained in:
Zhuhe Fang
2021-06-22 23:55:22 +08:00
committed by GitHub
parent 3602ddd44a
commit 9ca449b8bd
6 changed files with 147 additions and 108 deletions

View File

@ -380,7 +380,7 @@ func (s *tiflashTestSuite) TestTiFlashPartitionTableReader(c *C) {
tk.MustExec("SET tidb_enforce_mpp=1")
tk.MustExec("set @@session.tidb_isolation_read_engines='tiflash'")
for i := 0; i < 100; i++ {
for i := 0; i < 10; i++ {
l, r := rand.Intn(400), rand.Intn(400)
if l > r {
l, r = r, l

View File

@ -2003,13 +2003,25 @@ func (p *LogicalProjection) exhaustPhysicalPlans(prop *property.PhysicalProperty
if !ok {
return nil, true, nil
}
proj := PhysicalProjection{
Exprs: p.Exprs,
CalculateNoDelay: p.CalculateNoDelay,
AvoidColumnEvaluator: p.AvoidColumnEvaluator,
}.Init(p.ctx, p.stats.ScaleByExpectCnt(prop.ExpectedCnt), p.blockOffset, newProp)
proj.SetSchema(p.schema)
return []PhysicalPlan{proj}, true, nil
newProps := []*property.PhysicalProperty{newProp}
// generate a mpp task candidate if enforced mpp
if newProp.TaskTp != property.MppTaskType && p.SCtx().GetSessionVars().IsMPPEnforced() && p.canPushToCop(kv.TiFlash) &&
expression.CanExprsPushDown(p.SCtx().GetSessionVars().StmtCtx, p.Exprs, p.SCtx().GetClient(), kv.TiFlash) {
mppProp := newProp.CloneEssentialFields()
mppProp.TaskTp = property.MppTaskType
newProps = append(newProps, mppProp)
}
ret := make([]PhysicalPlan, 0, len(newProps))
for _, newProp := range newProps {
proj := PhysicalProjection{
Exprs: p.Exprs,
CalculateNoDelay: p.CalculateNoDelay,
AvoidColumnEvaluator: p.AvoidColumnEvaluator,
}.Init(p.ctx, p.stats.ScaleByExpectCnt(prop.ExpectedCnt), p.blockOffset, newProp)
proj.SetSchema(p.schema)
ret = append(ret, proj)
}
return ret, true, nil
}
func (lt *LogicalTopN) getPhysTopN(prop *property.PhysicalProperty) []PhysicalPlan {

View File

@ -3207,7 +3207,7 @@ func (s *testIntegrationSerialSuite) TestPushDownProjectionForMPP(c *C) {
}
}
tk.MustExec("set @@tidb_allow_mpp=1; set @@tidb_opt_broadcast_join=0;")
tk.MustExec("set @@tidb_allow_mpp=1; set @@tidb_opt_broadcast_join=0; set @@tidb_enforce_mpp=1;")
var input []string
var output []struct {

View File

@ -148,22 +148,22 @@
{
"SQL": "explain format='verbose' select count(*) from t where a=1",
"Plan": [
"HashAgg_24 1.00 33.60 root funcs:count(Column#6)->Column#4",
"└─TableReader_26 1.00 0.00 root data:ExchangeSender_25",
" └─ExchangeSender_25 1.00 285050.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg_9 1.00 285050.00 batchCop[tiflash] funcs:count(1)->Column#6",
" └─Selection_23 10.00 285020.00 batchCop[tiflash] eq(test.t.a, 1)",
" └─TableFullScan_22 10000.00 255020.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg_25 1.00 33.60 root funcs:count(Column#6)->Column#4",
"└─TableReader_27 1.00 0.00 root data:ExchangeSender_26",
" └─ExchangeSender_26 1.00 285050.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg_10 1.00 285050.00 batchCop[tiflash] funcs:count(1)->Column#6",
" └─Selection_24 10.00 285020.00 batchCop[tiflash] eq(test.t.a, 1)",
" └─TableFullScan_23 10000.00 255020.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
],
"Warn": null
},
{
"SQL": "explain format='verbose' select /*+ read_from_storage(tikv[t]) */ count(*) from t where a=1",
"Plan": [
"StreamAgg_18 1.00 485.00 root funcs:count(Column#6)->Column#4",
"└─IndexReader_19 1.00 32.88 root index:StreamAgg_10",
" └─StreamAgg_10 1.00 35.88 cop[tikv] funcs:count(1)->Column#6",
" └─IndexRangeScan_17 10.00 455.00 cop[tikv] table:t, index:idx(a) range:[1,1], keep order:false, stats:pseudo"
"StreamAgg_19 1.00 485.00 root funcs:count(Column#6)->Column#4",
"└─IndexReader_20 1.00 32.88 root index:StreamAgg_11",
" └─StreamAgg_11 1.00 35.88 cop[tikv] funcs:count(1)->Column#6",
" └─IndexRangeScan_18 10.00 455.00 cop[tikv] table:t, index:idx(a) range:[1,1], keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because you have set a hint to read table `t` from TiKV."
@ -172,12 +172,12 @@
{
"SQL": "explain format='verbose' select /*+ read_from_storage(tiflash[t]) */ count(*) from t where a=1",
"Plan": [
"HashAgg_21 1.00 33.60 root funcs:count(Column#6)->Column#4",
"└─TableReader_23 1.00 0.00 root data:ExchangeSender_22",
" └─ExchangeSender_22 1.00 285050.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg_9 1.00 285050.00 batchCop[tiflash] funcs:count(1)->Column#6",
" └─Selection_20 10.00 285020.00 batchCop[tiflash] eq(test.t.a, 1)",
" └─TableFullScan_19 10000.00 255020.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg_22 1.00 33.60 root funcs:count(Column#6)->Column#4",
"└─TableReader_24 1.00 0.00 root data:ExchangeSender_23",
" └─ExchangeSender_23 1.00 285050.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg_10 1.00 285050.00 batchCop[tiflash] funcs:count(1)->Column#6",
" └─Selection_21 10.00 285020.00 batchCop[tiflash] eq(test.t.a, 1)",
" └─TableFullScan_20 10000.00 255020.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
],
"Warn": null
}
@ -250,10 +250,10 @@
{
"SQL": "explain select /*+ read_from_storage(tikv[t]) */ count(*) from t where a=1 -- 4. hint use tikv",
"Plan": [
"StreamAgg_18 1.00 root funcs:count(Column#7)->Column#5",
"└─IndexReader_19 1.00 root index:StreamAgg_10",
" └─StreamAgg_10 1.00 cop[tikv] funcs:count(1)->Column#7",
" └─IndexRangeScan_17 10.00 cop[tikv] table:t, index:idx(a) range:[1,1], keep order:false, stats:pseudo"
"StreamAgg_19 1.00 root funcs:count(Column#7)->Column#5",
"└─IndexReader_20 1.00 root index:StreamAgg_11",
" └─StreamAgg_11 1.00 cop[tikv] funcs:count(1)->Column#7",
" └─IndexRangeScan_18 10.00 cop[tikv] table:t, index:idx(a) range:[1,1], keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because you have set a hint to read table `t` from TiKV."
@ -267,19 +267,20 @@
" └─IndexFullScan_8 10000.00 cop[tikv] table:t, index:idx(a) keep order:true, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because operator `Window` is not supported now.",
"MPP mode may be blocked because operator `Window` is not supported now."
]
},
{
"SQL": "EXPLAIN SELECT t1.b FROM t t1 join t t2 where t1.a=t2.a; -- 6. virtual column",
"Plan": [
"HashJoin_35 12487.50 root inner join, equal:[eq(test.t.a, test.t.a)]",
"├─TableReader_55(Build) 9990.00 root data:Selection_54",
"│ └─Selection_54 9990.00 cop[tiflash] not(isnull(test.t.a))",
"│ └─TableFullScan_53 10000.00 cop[tiflash] table:t2 keep order:false, stats:pseudo",
"└─TableReader_49(Probe) 9990.00 root data:Selection_48",
" └─Selection_48 9990.00 cop[tiflash] not(isnull(test.t.a))",
" └─TableFullScan_47 10000.00 cop[tiflash] table:t1 keep order:false, stats:pseudo"
"HashJoin_36 12487.50 root inner join, equal:[eq(test.t.a, test.t.a)]",
"├─TableReader_56(Build) 9990.00 root data:Selection_55",
"│ └─Selection_55 9990.00 cop[tiflash] not(isnull(test.t.a))",
"│ └─TableFullScan_54 10000.00 cop[tiflash] table:t2 keep order:false, stats:pseudo",
"└─TableReader_50(Probe) 9990.00 root data:Selection_49",
" └─Selection_49 9990.00 cop[tiflash] not(isnull(test.t.a))",
" └─TableFullScan_48 10000.00 cop[tiflash] table:t1 keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because column `test.t.b` is a virtual column which is not supported now."
@ -288,27 +289,29 @@
{
"SQL": "EXPLAIN SELECT count(b) from t where a=1; -- 7. agg func has virtual column",
"Plan": [
"StreamAgg_10 1.00 root funcs:count(test.t.b)->Column#5",
"└─IndexLookUp_41 10.00 root ",
" ├─IndexRangeScan_39(Build) 10.00 cop[tikv] table:t, index:idx(a) range:[1,1], keep order:false, stats:pseudo",
" └─TableRowIDScan_40(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo"
"StreamAgg_11 1.00 root funcs:count(test.t.b)->Column#5",
"└─IndexLookUp_42 10.00 root ",
" ├─IndexRangeScan_40(Build) 10.00 cop[tikv] table:t, index:idx(a) range:[1,1], keep order:false, stats:pseudo",
" └─TableRowIDScan_41(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because expressions of AggFunc `count` contain virtual column or correlated column, which is not supported now.",
"MPP mode may be blocked because expressions of AggFunc `count` contain virtual column or correlated column, which is not supported now.",
"MPP mode may be blocked because expressions of AggFunc `count` contain virtual column or correlated column, which is not supported now.",
"MPP mode may be blocked because expressions of AggFunc `count` contain virtual column or correlated column, which is not supported now.",
"MPP mode may be blocked because expressions of AggFunc `count` contain virtual column or correlated column, which is not supported now."
]
},
{
"SQL": "EXPLAIN SELECT count(*) from t group by b; -- 8. group by virtual column",
"Plan": [
"HashAgg_5 8000.00 root group by:test.t.b, funcs:count(1)->Column#5",
"└─Projection_11 10000.00 root test.t.b",
" └─TableReader_10 10000.00 root data:TableFullScan_9",
" └─TableFullScan_9 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg_6 8000.00 root group by:test.t.b, funcs:count(1)->Column#5",
"└─Projection_12 10000.00 root test.t.b",
" └─TableReader_11 10000.00 root data:TableFullScan_10",
" └─TableFullScan_10 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because groupByItems contain virtual column, which is not supported now.",
"MPP mode may be blocked because groupByItems contain virtual column, which is not supported now.",
"MPP mode may be blocked because groupByItems contain virtual column, which is not supported now."
]
@ -316,12 +319,13 @@
{
"SQL": "EXPLAIN SELECT group_concat(a) from t; -- 9. agg func not supported",
"Plan": [
"HashAgg_5 1.00 root funcs:group_concat(Column#6 separator \",\")->Column#5",
"└─Projection_30 10000.00 root cast(test.t.a, var_string(20))->Column#6",
" └─TableReader_13 10000.00 root data:TableFullScan_11",
" └─TableFullScan_11 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg_6 1.00 root funcs:group_concat(Column#6 separator \",\")->Column#5",
"└─Projection_31 10000.00 root cast(test.t.a, var_string(20))->Column#6",
" └─TableReader_14 10000.00 root data:TableFullScan_12",
" └─TableFullScan_12 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because AggFunc `group_concat` is not supported now.",
"MPP mode may be blocked because AggFunc `group_concat` is not supported now.",
"MPP mode may be blocked because AggFunc `group_concat` is not supported now.",
"MPP mode may be blocked because AggFunc `group_concat` is not supported now."
@ -330,12 +334,13 @@
{
"SQL": "EXPLAIN SELECT count(a) from t group by md5(a); -- 10. scalar func not supported",
"Plan": [
"HashAgg_5 8000.00 root group by:Column#7, funcs:count(Column#6)->Column#5",
"└─Projection_18 10000.00 root test.t.a, md5(cast(test.t.a, var_string(20)))->Column#7",
" └─TableReader_11 10000.00 root data:TableFullScan_9",
" └─TableFullScan_9 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg_6 8000.00 root group by:Column#7, funcs:count(Column#6)->Column#5",
"└─Projection_19 10000.00 root test.t.a, md5(cast(test.t.a, var_string(20)))->Column#7",
" └─TableReader_12 10000.00 root data:TableFullScan_10",
" └─TableFullScan_10 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
],
"Warn": [
"Scalar function 'md5'(signature: MD5) can not be pushed to tiflash",
"Scalar function 'md5'(signature: MD5) can not be pushed to tiflash",
"Scalar function 'md5'(signature: MD5) can not be pushed to tiflash"
]
@ -343,10 +348,10 @@
{
"SQL": "EXPLAIN SELECT count(a) from t where c=1; -- 11. type not supported",
"Plan": [
"HashAgg_6 1.00 root funcs:count(test.t.a)->Column#5",
"└─Selection_16 10000.00 root eq(test.t.c, 00:00:01.000000)",
" └─TableReader_15 10000.00 root data:TableFullScan_14",
" └─TableFullScan_14 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg_7 1.00 root funcs:count(test.t.a)->Column#5",
"└─Selection_17 10000.00 root eq(test.t.c, 00:00:01.000000)",
" └─TableReader_16 10000.00 root data:TableFullScan_15",
" └─TableFullScan_15 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
],
"Warn": [
"Expr 'test.t.c' can not be pushed to TiFlash because it contains Duration type",
@ -374,11 +379,11 @@
{
"SQL": "EXPLAIN SELECT count(*) from t where a=1; -- 12. static partition prune",
"Plan": [
"StreamAgg_31 1.00 root funcs:count(Column#6)->Column#4",
"└─TableReader_32 1.00 root data:StreamAgg_12",
" └─StreamAgg_12 1.00 batchCop[tiflash] funcs:count(1)->Column#6",
" └─Selection_30 10.00 batchCop[tiflash] eq(test.t.a, 1)",
" └─TableFullScan_29 10000.00 batchCop[tiflash] table:t, partition:p0 keep order:false, stats:pseudo"
"StreamAgg_32 1.00 root funcs:count(Column#6)->Column#4",
"└─TableReader_33 1.00 root data:StreamAgg_13",
" └─StreamAgg_13 1.00 batchCop[tiflash] funcs:count(1)->Column#6",
" └─Selection_31 10.00 batchCop[tiflash] eq(test.t.a, 1)",
" └─TableFullScan_30 10000.00 batchCop[tiflash] table:t, partition:p0 keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because table `t`is a partition table which is not supported when `@@tidb_partition_prune_mode=static`."
@ -407,13 +412,14 @@
{
"SQL": "EXPLAIN SELECT count(*) from t group by b; -- 13. new collation FIXME",
"Plan": [
"HashAgg_23 8000.00 root group by:test.t.b, funcs:count(Column#7)->Column#4",
"└─TableReader_25 8000.00 root data:ExchangeSender_24",
" └─ExchangeSender_24 8000.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg_10 8000.00 batchCop[tiflash] group by:test.t.b, funcs:count(1)->Column#7",
" └─TableFullScan_20 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg_24 8000.00 root group by:test.t.b, funcs:count(Column#7)->Column#4",
"└─TableReader_26 8000.00 root data:ExchangeSender_25",
" └─ExchangeSender_25 8000.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg_11 8000.00 batchCop[tiflash] group by:test.t.b, funcs:count(1)->Column#7",
" └─TableFullScan_21 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because when `new_collation_enabled` is true, HashJoin or HashAgg with string key is not supported now.",
"MPP mode may be blocked because when `new_collation_enabled` is true, HashJoin or HashAgg with string key is not supported now.",
"MPP mode may be blocked because when `new_collation_enabled` is true, HashJoin or HashAgg with string key is not supported now."
]
@ -421,15 +427,15 @@
{
"SQL": "EXPLAIN SELECT * from t t1 join t t2 on t1.b=t2.b; -- 13. new collation FIXME",
"Plan": [
"TableReader_18 12487.50 root data:ExchangeSender_17",
"└─ExchangeSender_17 12487.50 cop[tiflash] ExchangeType: PassThrough",
" └─HashJoin_8 12487.50 cop[tiflash] inner join, equal:[eq(test.t.b, test.t.b)]",
" ├─ExchangeReceiver_14(Build) 9990.00 cop[tiflash] ",
" │ └─ExchangeSender_13 9990.00 cop[tiflash] ExchangeType: Broadcast",
" │ └─Selection_12 9990.00 cop[tiflash] not(isnull(test.t.b))",
" │ └─TableFullScan_11 10000.00 cop[tiflash] table:t1 keep order:false, stats:pseudo",
" └─Selection_16(Probe) 9990.00 cop[tiflash] not(isnull(test.t.b))",
" └─TableFullScan_15 10000.00 cop[tiflash] table:t2 keep order:false, stats:pseudo"
"TableReader_34 12487.50 root data:ExchangeSender_33",
"└─ExchangeSender_33 12487.50 cop[tiflash] ExchangeType: PassThrough",
" └─HashJoin_32 12487.50 cop[tiflash] inner join, equal:[eq(test.t.b, test.t.b)]",
" ├─ExchangeReceiver_15(Build) 9990.00 cop[tiflash] ",
" │ └─ExchangeSender_14 9990.00 cop[tiflash] ExchangeType: Broadcast",
" │ └─Selection_13 9990.00 cop[tiflash] not(isnull(test.t.b))",
" │ └─TableFullScan_12 10000.00 cop[tiflash] table:t1 keep order:false, stats:pseudo",
" └─Selection_17(Probe) 9990.00 cop[tiflash] not(isnull(test.t.b))",
" └─TableFullScan_16 10000.00 cop[tiflash] table:t2 keep order:false, stats:pseudo"
],
"Warn": null
}

View File

@ -221,13 +221,14 @@
"desc format = 'brief' select /*+ stream_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ count(*) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ sum(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select * from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"desc format = 'brief' select B.b+A.b from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"desc format = 'brief' select * from t join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select * from t left join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select * from t right join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select A.b, B.b from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"desc format = 'brief' select id from t as A where exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' select id from t as A where not exists (select 1 from t where t.id=A.id)"
"desc format = 'brief' select id from t as A where not exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' select b*2, id from (select avg(value+2) as b, id from t group by id) C order by id"
]
},
{

View File

@ -1602,8 +1602,8 @@
"HashAgg 1.00 root funcs:count(Column#8)->Column#5",
"└─TableReader 1.00 root data:ExchangeSender",
" └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#9)->Column#8",
" └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#9",
" └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#10)->Column#8",
" └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#10",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
]
},
@ -1623,54 +1623,58 @@
"HashAgg 1.00 root funcs:sum(Column#8)->Column#5",
"└─TableReader 1.00 root data:ExchangeSender",
" └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#9)->Column#8",
" └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#9",
" └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#10)->Column#8",
" └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#10",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
]
},
{
"SQL": "desc format = 'brief' select /*+ stream_agg()*/ count(b) from (select id + 1 as b from t)A",
"Plan": [
"StreamAgg 1.00 root funcs:count(Column#7)->Column#5",
"└─TableReader 1.00 root data:StreamAgg",
" └─StreamAgg 1.00 batchCop[tiflash] funcs:count(Column#9)->Column#7",
" └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#9",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg 1.00 root funcs:count(Column#9)->Column#5",
"└─TableReader 1.00 root data:ExchangeSender",
" └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#10)->Column#9",
" └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#10",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
]
},
{
"SQL": "desc format = 'brief' select /*+ stream_agg()*/ count(*) from (select id + 1 as b from t)A",
"Plan": [
"StreamAgg 1.00 root funcs:count(Column#6)->Column#5",
"└─TableReader 1.00 root data:StreamAgg",
" └─StreamAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#6",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg 1.00 root funcs:count(Column#8)->Column#5",
"└─TableReader 1.00 root data:ExchangeSender",
" └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#8",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
]
},
{
"SQL": "desc format = 'brief' select /*+ stream_agg()*/ sum(b) from (select id + 1 as b from t)A",
"Plan": [
"StreamAgg 1.00 root funcs:sum(Column#7)->Column#5",
"└─TableReader 1.00 root data:StreamAgg",
" └─StreamAgg 1.00 batchCop[tiflash] funcs:sum(Column#9)->Column#7",
" └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#9",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
"HashAgg 1.00 root funcs:sum(Column#9)->Column#5",
"└─TableReader 1.00 root data:ExchangeSender",
" └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#10)->Column#9",
" └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#10",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
]
},
{
"SQL": "desc format = 'brief' select * from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"SQL": "desc format = 'brief' select B.b+A.b from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"Plan": [
"TableReader 10000.00 root data:ExchangeSender",
"└─ExchangeSender 10000.00 cop[tiflash] ExchangeType: PassThrough",
" └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#4, Column#8)]",
" ├─ExchangeReceiver(Build) 8000.00 cop[tiflash] ",
" │ └─ExchangeSender 8000.00 cop[tiflash] ExchangeType: Broadcast",
" └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#4",
" └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))",
" └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo",
" └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#8",
" └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))",
" └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
" └─Projection 10000.00 cop[tiflash] plus(Column#4, Column#8)->Column#9",
" └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#4, Column#8)]",
" ─ExchangeReceiver(Build) 8000.00 cop[tiflash] ",
" └─ExchangeSender 8000.00 cop[tiflash] ExchangeType: Broadcast",
" └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#4",
" └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))",
" │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo",
" └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#8",
" └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))",
" └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
]
},
{
@ -1719,9 +1723,9 @@
{
"SQL": "desc format = 'brief' select A.b, B.b from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"Plan": [
"Projection 10000.00 root Column#8, Column#4",
"└─TableReader 10000.00 root data:ExchangeSender",
" └─ExchangeSender 10000.00 cop[tiflash] ExchangeType: PassThrough",
"TableReader 10000.00 root data:ExchangeSender",
"└─ExchangeSender 10000.00 cop[tiflash] ExchangeType: PassThrough",
" └─Projection 10000.00 cop[tiflash] Column#8, Column#4",
" └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#4, Column#8)]",
" ├─ExchangeReceiver(Build) 8000.00 cop[tiflash] ",
" │ └─ExchangeSender 8000.00 cop[tiflash] ExchangeType: Broadcast",
@ -1758,6 +1762,22 @@
" │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo",
" └─TableFullScan(Probe) 10000.00 cop[tiflash] table:A keep order:false, stats:pseudo"
]
},
{
"SQL": "desc format = 'brief' select b*2, id from (select avg(value+2) as b, id from t group by id) C order by id",
"Plan": [
"Sort 8000.00 root test.t.id",
"└─TableReader 8000.00 root data:ExchangeSender",
" └─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: PassThrough",
" └─Projection 8000.00 batchCop[tiflash] mul(Column#4, 2)->Column#5, test.t.id",
" └─Projection 8000.00 batchCop[tiflash] div(Column#4, cast(case(eq(Column#19, 0), 1, Column#19), decimal(20,0) BINARY))->Column#4, test.t.id",
" └─HashAgg 8000.00 batchCop[tiflash] group by:test.t.id, funcs:sum(Column#20)->Column#19, funcs:sum(Column#21)->Column#4, funcs:firstrow(test.t.id)->test.t.id",
" └─ExchangeReceiver 8000.00 batchCop[tiflash] ",
" └─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: test.t.id",
" └─HashAgg 8000.00 batchCop[tiflash] group by:Column#25, funcs:count(Column#23)->Column#20, funcs:sum(Column#24)->Column#21",
" └─Projection 10000.00 batchCop[tiflash] plus(test.t.value, 2)->Column#23, plus(test.t.value, 2)->Column#24, test.t.id",
" └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo"
]
}
]
},