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: Do not pushdown unsupported function to tiflash in TopN operator #19363

Merged
merged 2 commits into from Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions planner/core/task.go
Expand Up @@ -904,11 +904,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
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
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",
"Plan": [
"Projection_17 2.00 root test.t.a, test.t.b",
"└─TopN_8 2.00 root Column#3, 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",
"Plan": [
"TopN_8 2.00 root test.t.b, offset:0, count:2",
"└─TableReader_17 2.00 root data:TopN_16",
" └─TopN_16 2.00 cop[tiflash] test.t.b, 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