Skip to content

Commit

Permalink
planner: Do not pushdown unsupported function to tiflash in ... (#19601)
Browse files Browse the repository at this point in the history
  • Loading branch information
windtalker authored Sep 1, 2020
1 parent 117f555 commit 5ea2b12
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
6 changes: 1 addition & 5 deletions planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,11 +887,7 @@ func (p *PhysicalTopN) canPushDown(cop *copTask) bool {
for _, item := range p.ByItems {
exprs = append(exprs, item.Expr)
}
storeType := kv.TiKV
if tableScan, ok := cop.tablePlan.(*PhysicalTableScan); ok {
storeType = tableScan.StoreType
}
return expression.CanExprsPushDown(p.ctx.GetSessionVars().StmtCtx, exprs, p.ctx.GetClient(), storeType)
return expression.CanExprsPushDown(p.ctx.GetSessionVars().StmtCtx, exprs, p.ctx.GetClient(), cop.getStoreType())
}

func (p *PhysicalTopN) allColsFromSchema(schema *expression.Schema) bool {
Expand Down
4 changes: 3 additions & 1 deletion planner/core/testdata/integration_serial_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"name": "TestSelPushDownTiFlash",
"cases": [
"explain select * from t where t.a > 1 and t.b = \"flash\" or t.a + 3 * t.a = 5",
"explain select * from t where cast(t.a as float) + 3 = 5.1"
"explain select * from t where cast(t.a as float) + 3 = 5.1",
"explain select * from t where b > 'a' order by convert(b, unsigned) limit 2",
"explain select * from t where b > 'a' order by b limit 2"
]
},
{
Expand Down
21 changes: 21 additions & 0 deletions planner/core/testdata/integration_serial_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@
"└─TableReader_6 10000.00 root data:TableFullScan_5",
" └─TableFullScan_5 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t where b > 'a' order by convert(b, unsigned) limit 2",
"Result": [
"Projection_17 2.00 root test.t.a, test.t.b",
"└─TopN_8 2.00 root Column#3:asc, offset:0, count:2",
" └─Projection_18 3333.33 root test.t.a, test.t.b, cast(test.t.b, bigint(22) UNSIGNED BINARY)->Column#3",
" └─TableReader_13 3333.33 root data:Selection_12",
" └─Selection_12 3333.33 cop[tiflash] gt(test.t.b, \"a\")",
" └─TableFullScan_11 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
]
},
{
"SQL": "explain select * from t where b > 'a' order by b limit 2",
"Result": [
"TopN_8 2.00 root test.t.b:asc, offset:0, count:2",
"└─TableReader_17 2.00 root data:TopN_16",
" └─TopN_16 2.00 cop[tiflash] test.t.b:asc, offset:0, count:2",
" └─Selection_15 3333.33 cop[tiflash] gt(test.t.b, \"a\")",
" └─TableFullScan_14 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo"
]
}
]
},
Expand Down

0 comments on commit 5ea2b12

Please sign in to comment.