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: add projection pushdown #27029

Merged
merged 151 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
90de1e9
add pushdown
ichn-hu Aug 5, 2021
a8fd00a
make linter happy
ichn-hu Mar 31, 2022
9d7dc84
fix test failure
ichn-hu Mar 31, 2022
9627dc1
Merge branch 'master' into add-projection-pushdown
ichn-hu Mar 31, 2022
a26c19b
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 1, 2022
81a7387
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 1, 2022
30aa8c4
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 1, 2022
587411d
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 1, 2022
d0a76de
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 1, 2022
923e4a3
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
8c67585
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
1dcabc1
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
030af59
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
bd4a28b
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
2bc1b86
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
3751e1a
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
91b7383
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
593ecfe
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
3cdefb6
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
e935a32
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
5d45302
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 2, 2022
b08449e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 3, 2022
3c40a69
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 4, 2022
034303a
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 4, 2022
e8935b3
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
cafcd19
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
8cbb39e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
295baa5
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
45542af
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
62b5cd3
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
457e345
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
41e1d41
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
33cd539
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 6, 2022
d9ab164
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
3416337
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
98e4cfd
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
696ac27
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
a7ce97c
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
f7df012
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
5983582
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
c0e840c
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
10b8846
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
0ce9d4e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
5f03bd1
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
ac5ff75
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
2851a76
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
a75851a
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
c008021
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
82ff054
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 7, 2022
3bd806e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
8385391
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
507b9bb
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
8ae4159
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
4f73ad8
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
f81bb24
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
4b6ca88
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
959e500
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
631bf52
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
ac74009
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 8, 2022
71070be
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 11, 2022
7c2f2b8
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 11, 2022
7201b5f
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 11, 2022
fc9223b
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 11, 2022
4919a6f
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 11, 2022
5399cd6
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 11, 2022
3ea08cf
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 11, 2022
a9e6377
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 12, 2022
5b2b3c1
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 12, 2022
88d7942
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 12, 2022
ffe75e1
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 12, 2022
3466633
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 12, 2022
0debd17
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 12, 2022
07b9b59
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
9cb4bad
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
9ed3c92
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
410f947
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
0f4ab3a
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
cb8c0c3
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
bf86298
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
b71bc21
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
8f08af6
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
905cb28
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
ac5dff6
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
324765c
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
4e01d81
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
065ebd7
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
8d768ce
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
bbc6f12
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
f755f89
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
27445fe
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 13, 2022
97d7eec
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
acf56a2
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
8904482
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
62b6cdb
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
71c4a11
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
40408bd
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
b7162e5
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
ce4f411
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
38451e4
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
2be2513
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 14, 2022
c812882
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
e92892e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
696711a
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
c3c25b1
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
ce0e277
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
2bd5e8d
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
355e93e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
bfd49ae
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
7f2f643
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
48347b1
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
9918dbc
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 15, 2022
db11fec
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 17, 2022
bb5e64b
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
a1d3afa
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
9b2e0c8
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
9d7df9a
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
984dd59
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
7d5f982
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
66f3798
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
9ecc9db
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
f9a1048
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
b940b81
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 18, 2022
290646e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
98abdac
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
9e13480
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
8e7513d
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
8d43c42
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
7dd4433
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
f20d7d9
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
0f0f535
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
3e173ce
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
bbeab78
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 19, 2022
e064fca
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
fcd9566
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
9f1156e
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
f28996f
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
9de9646
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
f1b0bc4
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
ec244db
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
3db871f
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
dae636d
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
f5c6d89
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
7d4de5d
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 20, 2022
fea55ca
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 21, 2022
3ad0c24
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 21, 2022
f1a1f25
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 21, 2022
9e9378d
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 21, 2022
0c375c2
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 21, 2022
de83aab
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 21, 2022
dbc3629
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 22, 2022
18970dc
Merge branch 'master' into add-projection-pushdown
ti-chi-bot Apr 22, 2022
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
7 changes: 5 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,10 @@ type Performance struct {
CrossJoin bool `toml:"cross-join" json:"cross-join"`
RunAutoAnalyze bool `toml:"run-auto-analyze" json:"run-auto-analyze"`
DistinctAggPushDown bool `toml:"distinct-agg-push-down" json:"distinct-agg-push-down"`
CommitterConcurrency int `toml:"committer-concurrency" json:"committer-concurrency"`
MaxTxnTTL uint64 `toml:"max-txn-ttl" json:"max-txn-ttl"`
// Whether enable projection push down for coprocessors (both tikv & tiflash), default false.
ProjectionPushDown bool `toml:"projection-push-down" json:"projection-push-down"`
CommitterConcurrency int `toml:"committer-concurrency" json:"committer-concurrency"`
MaxTxnTTL uint64 `toml:"max-txn-ttl" json:"max-txn-ttl"`
// Deprecated
MemProfileInterval string `toml:"-" json:"-"`
IndexUsageSyncLease string `toml:"index-usage-sync-lease" json:"index-usage-sync-lease"`
Expand Down Expand Up @@ -693,6 +695,7 @@ var defaultConf = Config{
TxnEntrySizeLimit: DefTxnEntrySizeLimit,
TxnTotalSizeLimit: DefTxnTotalSizeLimit,
DistinctAggPushDown: false,
ProjectionPushDown: false,
CommitterConcurrency: defTiKVCfg.CommitterConcurrency,
MaxTxnTTL: defTiKVCfg.MaxTxnTTL, // 1hour
// TODO: set indexUsageSyncLease to 60s.
Expand Down
7 changes: 7 additions & 0 deletions planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,13 @@ func (p *LogicalProjection) exhaustPhysicalPlans(prop *property.PhysicalProperty
mppProp.TaskTp = property.MppTaskType
newProps = append(newProps, mppProp)
}
if newProp.TaskTp != property.CopSingleReadTaskType && p.SCtx().GetSessionVars().AllowProjectionPushDown && p.canPushToCop(kv.TiKV) &&
expression.CanExprsPushDown(p.SCtx().GetSessionVars().StmtCtx, p.Exprs, p.SCtx().GetClient(), kv.TiKV) && !expression.ContainVirtualColumn(p.Exprs) {
copProp := newProp.CloneEssentialFields()
copProp.TaskTp = property.CopSingleReadTaskType
newProps = append(newProps, copProp)
}

ret := make([]PhysicalPlan, 0, len(newProps))
for _, newProp := range newProps {
proj := PhysicalProjection{
Expand Down
68 changes: 68 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4078,6 +4078,74 @@ func TestIssue32428(t *testing.T) {
tk.MustQuery(`execute stmt using @a`).Check(testkit.Rows()) // empty result
}

func TestPushDownProjectionForTiKV(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (a int, b real, i int, id int, value decimal(6,3), name char(128), d decimal(6,3), s char(128), t datetime, c bigint as ((a+1)) virtual, e real as ((b+a)))")
tk.MustExec("analyze table t")
tk.MustExec("set session tidb_opt_projection_push_down=1")

var input []string
var output []struct {
SQL string
Plan []string
}
integrationSuiteData := core.GetIntegrationSuiteData()
integrationSuiteData.GetTestCases(t, &input, &output)
for i, tt := range input {
testdata.OnRecord(func() {
output[i].SQL = tt
output[i].Plan = testdata.ConvertRowsToStrings(tk.MustQuery(tt).Rows())
})
res := tk.MustQuery(tt)
res.Check(testkit.Rows(output[i].Plan...))
}
}

func TestPushDownProjectionForTiFlashCoprocessor(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (a int, b real, i int, id int, value decimal(6,3), name char(128), d decimal(6,3), s char(128), t datetime, c bigint as ((a+1)) virtual, e real as ((b+a)))")
tk.MustExec("analyze table t")
tk.MustExec("set session tidb_opt_projection_push_down=1")

// Create virtual tiflash replica info.
dom := domain.GetDomain(tk.Session())
is := dom.InfoSchema()
db, exists := is.SchemaByName(model.NewCIStr("test"))
require.True(t, exists)
for _, tblInfo := range db.Tables {
if tblInfo.Name.L == "t" {
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
Count: 1,
Available: true,
}
}
}

var input []string
var output []struct {
SQL string
Plan []string
}
integrationSuiteData := core.GetIntegrationSuiteData()
integrationSuiteData.GetTestCases(t, &input, &output)
for i, tt := range input {
testdata.OnRecord(func() {
output[i].SQL = tt
output[i].Plan = testdata.ConvertRowsToStrings(tk.MustQuery(tt).Rows())
})
res := tk.MustQuery(tt)
res.Check(testkit.Rows(output[i].Plan...))
}
}

func TestPushDownProjectionForTiFlash(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
Expand Down
2 changes: 1 addition & 1 deletion planner/core/physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (p *PhysicalIndexReader) SetSchema(_ *expression.Schema) {
if p.indexPlan != nil {
p.IndexPlans = flattenPushDownPlan(p.indexPlan)
switch p.indexPlan.(type) {
case *PhysicalHashAgg, *PhysicalStreamAgg:
case *PhysicalHashAgg, *PhysicalStreamAgg, *PhysicalProjection:
p.schema = p.indexPlan.Schema()
default:
is := p.IndexPlans[0].(*PhysicalIndexScan)
Expand Down
4 changes: 2 additions & 2 deletions planner/core/plan_to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ func (p *PhysicalProjection) ToPB(ctx sessionctx.Context, storeType kv.StoreType
Exprs: exprs,
}
executorID := ""
if storeType == kv.TiFlash {
if storeType == kv.TiFlash || storeType == kv.TiKV {
var err error
projExec.Child, err = p.children[0].ToPB(ctx, storeType)
if err != nil {
return nil, errors.Trace(err)
}
executorID = p.ExplainID().String()
} else {
return nil, errors.Errorf("The projection can only be pushed down to TiFlash now, not %s", storeType.Name())
return nil, errors.Errorf("the projection can only be pushed down to TiFlash or TiKV now, not %s", storeType.Name())
}
return &tipb.Executor{Tp: tipb.ExecType_TypeProjection, Projection: projExec, ExecutorId: &executorID}, nil
}
Expand Down
3 changes: 1 addition & 2 deletions planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ func (p *PhysicalProjection) GetCost(count float64) float64 {
func (p *PhysicalProjection) attach2Task(tasks ...task) task {
t := tasks[0].copy()
if cop, ok := t.(*copTask); ok {
if len(cop.rootTaskConds) == 0 && cop.getStoreType() == kv.TiFlash && expression.CanExprsPushDown(p.ctx.GetSessionVars().StmtCtx, p.Exprs, p.ctx.GetClient(), cop.getStoreType()) {
if len(cop.rootTaskConds) == 0 && expression.CanExprsPushDown(p.ctx.GetSessionVars().StmtCtx, p.Exprs, p.ctx.GetClient(), cop.getStoreType()) {
copTask := attachPlan2Task(p, cop)
copTask.addCost(p.GetCost(t.count()))
p.cost = copTask.cost()
Expand All @@ -1475,7 +1475,6 @@ func (p *PhysicalProjection) attach2Task(tasks ...task) task {
return mpp
}
}
// TODO: support projection push down for TiKV.
t = t.convertToRootTask(p.ctx)
t = attachPlan2Task(p, t)
t.addCost(p.GetCost(t.count()))
Expand Down
46 changes: 46 additions & 0 deletions planner/core/testdata/integration_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,52 @@
"explain format = 'brief' select /*+ inl_hash_join(s) */ * from t join s on t.a=s.a and t.a = s.b"
]
},
{
"name": "TestPushDownProjectionForTiKV",
"cases": [
"desc format = 'brief' select i * 2 from t",
"desc format = 'brief' select DATE_FORMAT(t, '%Y-%m-%d %H') as date from t",
"desc format = 'brief' select md5(s) from t",
"desc format = 'brief' select c from t where a+1=3",
"desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ count(*) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ sum(b) from (select id + 1 as b from t)A",
"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 * 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 A.id from t as A where exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' select A.id from t as A where not exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' SELECT FROM_UNIXTIME(name,'%Y-%m-%d') FROM t;"
]
},
{
"name": "TestPushDownProjectionForTiFlashCoprocessor",
"cases": [
"desc format = 'brief' select i * 2 from t",
"desc format = 'brief' select DATE_FORMAT(t, '%Y-%m-%d %H') as date from t",
"desc format = 'brief' select md5(s) from t",
"desc format = 'brief' select c from t where a+1=3",
"desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ count(*) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ sum(b) from (select id + 1 as b from t)A",
"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 * 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 A.id from t as A where exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' select A.id from t as A where not exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' SELECT FROM_UNIXTIME(name,'%Y-%m-%d') FROM t;"
]
},
{
"name": "TestPushDownProjectionForTiFlash",
"cases": [
Expand Down
Loading