From 7c4a87605b555b1c94f4dc3a5435339564e34222 Mon Sep 17 00:00:00 2001 From: Lonng Date: Sun, 1 Dec 2019 12:31:32 +0800 Subject: [PATCH 1/6] expression: open CAST function push down switcher Signed-off-by: Lonng --- expression/expr_to_pb.go | 33 +++++++++++++++++-- expression/expr_to_pb_test.go | 9 +++-- .../testdata/plan_suite_unexported_out.json | 4 +-- util/codec/codec.go | 11 ++++++- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/expression/expr_to_pb.go b/expression/expr_to_pb.go index 515b2f5f13795..4ae5e6db1fd23 100644 --- a/expression/expr_to_pb.go +++ b/expression/expr_to_pb.go @@ -394,12 +394,41 @@ func (pc PbConverter) canFuncBePushed(sf *ScalarFunction) bool { // date functions. ast.DateFormat: - _, disallowPushdown := DefaultExprPushdownBlacklist.Load().(map[string]struct{})[sf.FuncName.L] - return true && !disallowPushdown + return isPushdownEnabled(sf.FuncName.L) + + case ast.Cast: + // Disable time related cast function temporarily + switch sf.Function.PbCode() { + case tipb.ScalarFuncSig_CastIntAsReal, + tipb.ScalarFuncSig_CastStringAsReal, + tipb.ScalarFuncSig_CastDurationAsDecimal, + tipb.ScalarFuncSig_CastDecimalAsString, + tipb.ScalarFuncSig_CastTimeAsInt, + tipb.ScalarFuncSig_CastTimeAsReal, + tipb.ScalarFuncSig_CastTimeAsDecimal, + tipb.ScalarFuncSig_CastTimeAsString, + tipb.ScalarFuncSig_CastTimeAsDuration, + tipb.ScalarFuncSig_CastTimeAsJson, + tipb.ScalarFuncSig_CastIntAsTime, + tipb.ScalarFuncSig_CastRealAsTime, + tipb.ScalarFuncSig_CastDecimalAsTime, + tipb.ScalarFuncSig_CastStringAsTime, + tipb.ScalarFuncSig_CastDurationAsTime, + tipb.ScalarFuncSig_CastJsonAsTime, + tipb.ScalarFuncSig_CastTimeAsTime: + return false + default: + return isPushdownEnabled(sf.FuncName.L) + } } return false } +func isPushdownEnabled(name string) bool { + _, disallowPushdown := DefaultExprPushdownBlacklist.Load().(map[string]struct{})[name] + return !disallowPushdown +} + // DefaultExprPushdownBlacklist indicates the expressions which can not be pushed down to TiKV. var DefaultExprPushdownBlacklist *atomic.Value diff --git a/expression/expr_to_pb_test.go b/expression/expr_to_pb_test.go index e8b4116cbd5f8..2e14105a58534 100644 --- a/expression/expr_to_pb_test.go +++ b/expression/expr_to_pb_test.go @@ -297,11 +297,16 @@ func (s *testEvaluatorSuite) TestLikeFunc2Pb(c *C) { c.Assert(err, IsNil) likeFuncs = append(likeFuncs, fc) + jsResults := []string{ + `{"tp":10000,"children":[{"tp":5,"val":"c3RyaW5n","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":5,"val":"cGF0dGVybg==","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":10000,"val":"CAA=","children":[{"tp":5,"val":"XA==","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}}],"sig":30,"field_type":{"tp":8,"flag":128,"flen":-1,"decimal":0,"collate":63,"charset":"binary"}}],"sig":4310,"field_type":{"tp":8,"flag":128,"flen":1,"decimal":0,"collate":63,"charset":"binary"}}`, + `{"tp":10000,"children":[{"tp":5,"val":"c3RyaW5n","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":5,"val":"JWFiYyU=","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":10000,"val":"CAA=","children":[{"tp":5,"val":"XA==","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}}],"sig":30,"field_type":{"tp":8,"flag":128,"flen":-1,"decimal":0,"collate":63,"charset":"binary"}}],"sig":4310,"field_type":{"tp":8,"flag":128,"flen":1,"decimal":0,"collate":63,"charset":"binary"}}`, + } + pbExprs := ExpressionsToPBList(sc, likeFuncs, client) - for _, pbExpr := range pbExprs { + for i, pbExpr := range pbExprs { js, err := json.Marshal(pbExpr) c.Assert(err, IsNil) - c.Assert(string(js), Equals, "null") + c.Assert(string(js), Equals, jsResults[i], Commentf("index: %d", i)) } } diff --git a/planner/core/testdata/plan_suite_unexported_out.json b/planner/core/testdata/plan_suite_unexported_out.json index 3b6697ccca304..ed2b9c657a27f 100644 --- a/planner/core/testdata/plan_suite_unexported_out.json +++ b/planner/core/testdata/plan_suite_unexported_out.json @@ -58,7 +58,7 @@ "DataScan(t)->Projection->Projection", "DataScan(t)->Projection->Projection", "Join{DataScan(ta)->DataScan(tb)}(test.t.d,test.t.b)(test.t.a,test.t.c)->Projection", - "Join{DataScan(t1)->Sel([like(cast(test.t.d), abc, 92)])->DataScan(t2)->Sel([like(cast(test.t.d), abc, 92)])}(test.t.a,test.t.b)(test.t.d,test.t.d)->Projection", + "Join{DataScan(t1)->DataScan(t2)}(test.t.a,test.t.b)(test.t.d,test.t.d)->Projection", "Join{DataScan(ta)->DataScan(tb)}(test.t.d,test.t.d)->Projection", "Join{DataScan(ta)->DataScan(tb)}(test.t.d,test.t.d)->Projection", "Join{DataScan(ta)->DataScan(tb)}(test.t.d,test.t.d)->Projection", @@ -882,4 +882,4 @@ } ] } -] +] \ No newline at end of file diff --git a/util/codec/codec.go b/util/codec/codec.go index 4f1abc17f26dc..94443768bec31 100644 --- a/util/codec/codec.go +++ b/util/codec/codec.go @@ -984,10 +984,19 @@ func (decoder *Decoder) DecodeOne(b []byte, colIdx int, ft *types.FieldType) (re chk.AppendBytes(colIdx, v) case decimalFlag: var dec *types.MyDecimal - b, dec, _, _, err = DecodeDecimal(b) + var frac int + b, dec, _, frac, err = DecodeDecimal(b) if err != nil { return nil, errors.Trace(err) } + if ft.Decimal != types.UnspecifiedLength && frac > ft.Decimal { + to := new(types.MyDecimal) + err := dec.Round(to, ft.Decimal, types.ModeHalfEven) + if err != nil { + return nil, errors.Trace(err) + } + dec = to + } chk.AppendMyDecimal(colIdx, dec) case durationFlag: var r int64 From 377c449c6c4ef6d5f02296724d1377a5a5d9777f Mon Sep 17 00:00:00 2001 From: Lonng Date: Tue, 31 Dec 2019 14:10:00 +0800 Subject: [PATCH 2/6] fix execution plan Signed-off-by: Lonng --- cmd/explaintest/r/explain_easy.result | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/explaintest/r/explain_easy.result b/cmd/explaintest/r/explain_easy.result index 656a48bad04be..8ed096e38ad1d 100644 --- a/cmd/explaintest/r/explain_easy.result +++ b/cmd/explaintest/r/explain_easy.result @@ -498,19 +498,17 @@ EXPLAIN SELECT COUNT(1) FROM (SELECT COALESCE(b.region_name, '不详') region_na id count task operator info StreamAgg_22 1.00 root funcs:count(1)->Column#22 └─HashAgg_25 1.00 root group by:Column#31, Column#32, Column#33, funcs:firstrow(1)->Column#23 - └─Projection_50 0.02 root Column#14, Column#15, coalesce(test.test02.region_name, 不详)->Column#33 + └─Projection_48 0.02 root Column#14, Column#15, coalesce(test.test02.region_name, 不详)->Column#33 └─IndexMergeJoin_32 0.02 root left outer join, inner:TableReader_30, outer key:Column#16, inner key:test.test02.id ├─Union_37 0.02 root │ ├─Projection_38 0.01 root test.test01.stat_date, test.test01.show_date, test.test01.region_id, cast(0)->Column#17 - │ │ └─Selection_39 0.01 root gt(cast(0), 0) - │ │ └─TableReader_42 0.01 root data:Selection_41 - │ │ └─Selection_41 0.01 cop[tikv] eq(test.test01.period, 1), ge(test.test01.stat_date, 20191202), ge(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202) - │ │ └─TableScan_40 10000.00 cop[tikv] table:test01, range:[-inf,+inf], keep order:false, stats:pseudo - │ └─Projection_43 0.01 root test.test01.stat_date, test.test01.show_date, test.test01.region_id, cast(test.test01.registration_num)->Column#17 - │ └─Selection_44 0.01 root gt(cast(test.test01.registration_num), 0) - │ └─TableReader_47 0.01 root data:Selection_46 - │ └─Selection_46 0.01 cop[tikv] eq(test.test01.period, 1), ge(test.test01.stat_date, 20191202), ge(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202) - │ └─TableScan_45 10000.00 cop[tikv] table:test01, range:[-inf,+inf], keep order:false, stats:pseudo + │ │ └─TableReader_41 0.01 root data:Selection_40 + │ │ └─Selection_40 0.01 cop[tikv] eq(test.test01.period, 1), ge(test.test01.stat_date, 20191202), ge(test.test01.stat_date, 20191202), gt(cast(0), 0), le(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202) + │ │ └─TableScan_39 10000.00 cop[tikv] table:test01, range:[-inf,+inf], keep order:false, stats:pseudo + │ └─Projection_42 0.01 root test.test01.stat_date, test.test01.show_date, test.test01.region_id, cast(test.test01.registration_num)->Column#17 + │ └─TableReader_45 0.01 root data:Selection_44 + │ └─Selection_44 0.01 cop[tikv] eq(test.test01.period, 1), ge(test.test01.stat_date, 20191202), ge(test.test01.stat_date, 20191202), gt(cast(test.test01.registration_num), 0), le(test.test01.stat_date, 20191202), le(test.test01.stat_date, 20191202) + │ └─TableScan_43 10000.00 cop[tikv] table:test01, range:[-inf,+inf], keep order:false, stats:pseudo └─TableReader_30 1.00 root data:TableScan_29 └─TableScan_29 1.00 cop[tikv] table:b, range: decided by [Column#16], keep order:true, stats:pseudo drop table if exists t; From a108d284223ed57959dcf0e9eff151c0c66bcedc Mon Sep 17 00:00:00 2001 From: Lonng Date: Tue, 31 Dec 2019 14:19:54 +0800 Subject: [PATCH 3/6] fix ci Signed-off-by: Lonng --- planner/core/testdata/integration_suite_out.json | 12 ++++++------ planner/core/testdata/plan_suite_unexported_out.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/planner/core/testdata/integration_suite_out.json b/planner/core/testdata/integration_suite_out.json index c4b846647615e..b56533b75994a 100644 --- a/planner/core/testdata/integration_suite_out.json +++ b/planner/core/testdata/integration_suite_out.json @@ -68,12 +68,12 @@ { "SQL": "explain select * from t t1 left join t t2 on t1.a = t2.a where cast(t1.b as date) >= '2019-01-01'", "Plan": [ - "HashLeftJoin_9 10000.00 root left outer join, inner:Selection_10 (REVERSED), equal:[eq(test.t.a, test.t.a)]", - "├─Selection_10 8000.00 root ge(cast(test.t.b), 2019-01-01 00:00:00.000000)", - "│ └─TableReader_12 10000.00 root data:TableScan_11", - "│ └─TableScan_11 10000.00 cop[tikv] table:t1, range:[-inf,+inf], keep order:false, stats:pseudo", - "└─TableReader_14 10000.00 root data:TableScan_13", - " └─TableScan_13 10000.00 cop[tikv] table:t2, range:[-inf,+inf], keep order:false, stats:pseudo" + "HashLeftJoin_8 10000.00 root left outer join, inner:TableReader_11 (REVERSED), equal:[eq(test.t.a, test.t.a)]", + "├─TableReader_11 8000.00 root data:Selection_10", + "│ └─Selection_10 8000.00 cop[tikv] ge(cast(test.t.b), 2019-01-01 00:00:00.000000)", + "│ └─TableScan_9 10000.00 cop[tikv] table:t1, range:[-inf,+inf], keep order:false, stats:pseudo", + "└─TableReader_13 10000.00 root data:TableScan_12", + " └─TableScan_12 10000.00 cop[tikv] table:t2, range:[-inf,+inf], keep order:false, stats:pseudo" ] } ] diff --git a/planner/core/testdata/plan_suite_unexported_out.json b/planner/core/testdata/plan_suite_unexported_out.json index 29adbee95fecf..f7118690ca58f 100644 --- a/planner/core/testdata/plan_suite_unexported_out.json +++ b/planner/core/testdata/plan_suite_unexported_out.json @@ -883,4 +883,4 @@ } ] } -] \ No newline at end of file +] From ad164338932c8e7d6a39e4605f59fdcb84889907 Mon Sep 17 00:00:00 2001 From: Lonng Date: Tue, 31 Dec 2019 14:30:19 +0800 Subject: [PATCH 4/6] fix ci Signed-off-by: Lonng --- expression/expr_to_pb_test.go | 9 +- .../transformation_rules_suite_out.json | 189 +++++++++--------- 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/expression/expr_to_pb_test.go b/expression/expr_to_pb_test.go index b74ffcaf25c90..668e11430de3f 100644 --- a/expression/expr_to_pb_test.go +++ b/expression/expr_to_pb_test.go @@ -297,16 +297,11 @@ func (s *testEvaluatorSuite) TestLikeFunc2Pb(c *C) { c.Assert(err, IsNil) likeFuncs = append(likeFuncs, fc) - jsResults := []string{ - `{"tp":10000,"children":[{"tp":5,"val":"c3RyaW5n","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":5,"val":"cGF0dGVybg==","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":10000,"val":"CAA=","children":[{"tp":5,"val":"XA==","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}}],"sig":30,"field_type":{"tp":8,"flag":128,"flen":-1,"decimal":0,"collate":63,"charset":"binary"}}],"sig":4310,"field_type":{"tp":8,"flag":128,"flen":1,"decimal":0,"collate":63,"charset":"binary"}}`, - `{"tp":10000,"children":[{"tp":5,"val":"c3RyaW5n","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":5,"val":"JWFiYyU=","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}},{"tp":10000,"val":"CAA=","children":[{"tp":5,"val":"XA==","sig":0,"field_type":{"tp":254,"flag":0,"flen":-1,"decimal":-1,"collate":83,"charset":"utf8"}}],"sig":30,"field_type":{"tp":8,"flag":128,"flen":-1,"decimal":0,"collate":63,"charset":"binary"}}],"sig":4310,"field_type":{"tp":8,"flag":128,"flen":1,"decimal":0,"collate":63,"charset":"binary"}}`, - } - pbExprs := ExpressionsToPBList(sc, likeFuncs, client) - for i, pbExpr := range pbExprs { + for _, pbExpr := range pbExprs { js, err := json.Marshal(pbExpr) c.Assert(err, IsNil) - c.Assert(string(js), Equals, jsResults[i], Commentf("index: %d", i)) + c.Assert(string(js), Equals, "null") } } diff --git a/planner/cascades/testdata/transformation_rules_suite_out.json b/planner/cascades/testdata/transformation_rules_suite_out.json index 84c0c9cf26fe3..7dcbf11c28bbf 100644 --- a/planner/cascades/testdata/transformation_rules_suite_out.json +++ b/planner/cascades/testdata/transformation_rules_suite_out.json @@ -319,10 +319,15 @@ " Projection_3 input:[Group#1], test.t.b, Column#13", "Group#1 Schema:[Column#13,test.t.b]", " Aggregation_2 input:[Group#2], group by:plus(sin(cast(test.t.b)), sin(cast(test.t.c))), test.t.b, funcs:sum(test.t.a), firstrow(test.t.b)", + " Aggregation_7 input:[Group#3], group by:Column#16, test.t.b, funcs:sum(Column#14), firstrow(test.t.b)", "Group#2 Schema:[test.t.a,test.t.b,test.t.c], UniqueKey:[test.t.a]", - " TiKVSingleGather_5 input:[Group#3], table:t", - "Group#3 Schema:[test.t.a,test.t.b,test.t.c], UniqueKey:[test.t.a]", - " TableScan_4 table:t, pk col:test.t.a" + " TiKVSingleGather_5 input:[Group#4], table:t", + "Group#4 Schema:[test.t.a,test.t.b,test.t.c], UniqueKey:[test.t.a]", + " TableScan_4 table:t, pk col:test.t.a", + "Group#3 Schema:[Column#14,Column#16,test.t.b]", + " TiKVSingleGather_5 input:[Group#5], table:t", + "Group#5 Schema:[Column#14,Column#16,test.t.b]", + " Aggregation_6 input:[Group#4], group by:plus(sin(cast(test.t.b)), sin(cast(test.t.c))), test.t.b, funcs:sum(test.t.a)" ] } ] @@ -350,13 +355,13 @@ { "SQL": "select b from t limit 2", "Result": [ - "Group#0 Schema:[test.t.b]", - " Projection_2 input:[Group#1], test.t.b", - "Group#1 Schema:[test.t.b]", - " Limit_3 input:[Group#2], offset:0, count:2", - "Group#2 Schema:[test.t.b]", - " TiKVSingleGather_5 input:[Group#3], table:t", - "Group#3 Schema:[test.t.b]", + "Group#0 Schema:[test.t.b]", + " Projection_2 input:[Group#1], test.t.b", + "Group#1 Schema:[test.t.b]", + " Limit_3 input:[Group#2], offset:0, count:2", + "Group#2 Schema:[test.t.b]", + " TiKVSingleGather_5 input:[Group#3], table:t", + "Group#3 Schema:[test.t.b]", " TableScan_4 table:t" ] }, @@ -579,94 +584,94 @@ { "SQL": "(select a from t) union all (select b from t) limit 2;", "Result": [ - "Group#0 Schema:[Column#25]", - " Limit_8 input:[Group#1], offset:0, count:2", - "Group#1 Schema:[Column#25]", - " Union_5 input:[Group#2,Group#3]", - "Group#2 Schema:[Column#25]", - " Projection_6 input:[Group#4], test.t.a", - "Group#4 Schema:[test.t.a]", - " Projection_4 input:[Group#5], test.t.a", - "Group#5 Schema:[test.t.a]", - " Limit_25 input:[Group#6], offset:0, count:2", - "Group#6 Schema:[test.t.a]", - " TiKVSingleGather_10 input:[Group#7], table:t", - " TiKVSingleGather_22 input:[Group#8], table:t, index:e_d_c_str_prefix", - " TiKVSingleGather_20 input:[Group#9], table:t, index:c_d_e_str", - " TiKVSingleGather_18 input:[Group#10], table:t, index:f_g", - " TiKVSingleGather_16 input:[Group#11], table:t, index:g", - " TiKVSingleGather_14 input:[Group#12], table:t, index:f", - " TiKVSingleGather_12 input:[Group#13], table:t, index:c_d_e", - "Group#7 Schema:[test.t.a]", - " TableScan_9 table:t, pk col:test.t.a", - "Group#8 Schema:[test.t.a]", - " IndexScan_21 table:t, index:e_str, d_str, c_str", - "Group#9 Schema:[test.t.a]", - " IndexScan_19 table:t, index:c_str, d_str, e_str", - "Group#10 Schema:[test.t.a]", - " IndexScan_17 table:t, index:f, g", - "Group#11 Schema:[test.t.a]", - " IndexScan_15 table:t, index:g", - "Group#12 Schema:[test.t.a]", - " IndexScan_13 table:t, index:f", - "Group#13 Schema:[test.t.a]", - " IndexScan_11 table:t, index:c, d, e", - "Group#3 Schema:[Column#25]", - " Projection_7 input:[Group#14], test.t.b", - "Group#14 Schema:[test.t.b]", - " Projection_2 input:[Group#15], test.t.b", - "Group#15 Schema:[test.t.b]", - " Limit_25 input:[Group#16], offset:0, count:2", - "Group#16 Schema:[test.t.b]", - " TiKVSingleGather_24 input:[Group#17], table:t", - "Group#17 Schema:[test.t.b]", + "Group#0 Schema:[Column#25]", + " Limit_8 input:[Group#1], offset:0, count:2", + "Group#1 Schema:[Column#25]", + " Union_5 input:[Group#2,Group#3]", + "Group#2 Schema:[Column#25]", + " Projection_6 input:[Group#4], test.t.a", + "Group#4 Schema:[test.t.a]", + " Projection_4 input:[Group#5], test.t.a", + "Group#5 Schema:[test.t.a]", + " Limit_25 input:[Group#6], offset:0, count:2", + "Group#6 Schema:[test.t.a]", + " TiKVSingleGather_10 input:[Group#7], table:t", + " TiKVSingleGather_22 input:[Group#8], table:t, index:e_d_c_str_prefix", + " TiKVSingleGather_20 input:[Group#9], table:t, index:c_d_e_str", + " TiKVSingleGather_18 input:[Group#10], table:t, index:f_g", + " TiKVSingleGather_16 input:[Group#11], table:t, index:g", + " TiKVSingleGather_14 input:[Group#12], table:t, index:f", + " TiKVSingleGather_12 input:[Group#13], table:t, index:c_d_e", + "Group#7 Schema:[test.t.a]", + " TableScan_9 table:t, pk col:test.t.a", + "Group#8 Schema:[test.t.a]", + " IndexScan_21 table:t, index:e_str, d_str, c_str", + "Group#9 Schema:[test.t.a]", + " IndexScan_19 table:t, index:c_str, d_str, e_str", + "Group#10 Schema:[test.t.a]", + " IndexScan_17 table:t, index:f, g", + "Group#11 Schema:[test.t.a]", + " IndexScan_15 table:t, index:g", + "Group#12 Schema:[test.t.a]", + " IndexScan_13 table:t, index:f", + "Group#13 Schema:[test.t.a]", + " IndexScan_11 table:t, index:c, d, e", + "Group#3 Schema:[Column#25]", + " Projection_7 input:[Group#14], test.t.b", + "Group#14 Schema:[test.t.b]", + " Projection_2 input:[Group#15], test.t.b", + "Group#15 Schema:[test.t.b]", + " Limit_25 input:[Group#16], offset:0, count:2", + "Group#16 Schema:[test.t.b]", + " TiKVSingleGather_24 input:[Group#17], table:t", + "Group#17 Schema:[test.t.b]", " TableScan_23 table:t" ] }, { "SQL": "(select a from t) union all (select b from t) limit 2 offset 5;", "Result": [ - "Group#0 Schema:[Column#25]", - " Limit_8 input:[Group#1], offset:5, count:2", - "Group#1 Schema:[Column#25]", - " Union_5 input:[Group#2,Group#3]", - "Group#2 Schema:[Column#25]", - " Projection_6 input:[Group#4], test.t.a", - "Group#4 Schema:[test.t.a]", - " Projection_4 input:[Group#5], test.t.a", - "Group#5 Schema:[test.t.a]", - " Limit_25 input:[Group#6], offset:0, count:7", - "Group#6 Schema:[test.t.a]", - " TiKVSingleGather_10 input:[Group#7], table:t", - " TiKVSingleGather_22 input:[Group#8], table:t, index:e_d_c_str_prefix", - " TiKVSingleGather_20 input:[Group#9], table:t, index:c_d_e_str", - " TiKVSingleGather_18 input:[Group#10], table:t, index:f_g", - " TiKVSingleGather_16 input:[Group#11], table:t, index:g", - " TiKVSingleGather_14 input:[Group#12], table:t, index:f", - " TiKVSingleGather_12 input:[Group#13], table:t, index:c_d_e", - "Group#7 Schema:[test.t.a]", - " TableScan_9 table:t, pk col:test.t.a", - "Group#8 Schema:[test.t.a]", - " IndexScan_21 table:t, index:e_str, d_str, c_str", - "Group#9 Schema:[test.t.a]", - " IndexScan_19 table:t, index:c_str, d_str, e_str", - "Group#10 Schema:[test.t.a]", - " IndexScan_17 table:t, index:f, g", - "Group#11 Schema:[test.t.a]", - " IndexScan_15 table:t, index:g", - "Group#12 Schema:[test.t.a]", - " IndexScan_13 table:t, index:f", - "Group#13 Schema:[test.t.a]", - " IndexScan_11 table:t, index:c, d, e", - "Group#3 Schema:[Column#25]", - " Projection_7 input:[Group#14], test.t.b", - "Group#14 Schema:[test.t.b]", - " Projection_2 input:[Group#15], test.t.b", - "Group#15 Schema:[test.t.b]", - " Limit_25 input:[Group#16], offset:0, count:7", - "Group#16 Schema:[test.t.b]", - " TiKVSingleGather_24 input:[Group#17], table:t", - "Group#17 Schema:[test.t.b]", + "Group#0 Schema:[Column#25]", + " Limit_8 input:[Group#1], offset:5, count:2", + "Group#1 Schema:[Column#25]", + " Union_5 input:[Group#2,Group#3]", + "Group#2 Schema:[Column#25]", + " Projection_6 input:[Group#4], test.t.a", + "Group#4 Schema:[test.t.a]", + " Projection_4 input:[Group#5], test.t.a", + "Group#5 Schema:[test.t.a]", + " Limit_25 input:[Group#6], offset:0, count:7", + "Group#6 Schema:[test.t.a]", + " TiKVSingleGather_10 input:[Group#7], table:t", + " TiKVSingleGather_22 input:[Group#8], table:t, index:e_d_c_str_prefix", + " TiKVSingleGather_20 input:[Group#9], table:t, index:c_d_e_str", + " TiKVSingleGather_18 input:[Group#10], table:t, index:f_g", + " TiKVSingleGather_16 input:[Group#11], table:t, index:g", + " TiKVSingleGather_14 input:[Group#12], table:t, index:f", + " TiKVSingleGather_12 input:[Group#13], table:t, index:c_d_e", + "Group#7 Schema:[test.t.a]", + " TableScan_9 table:t, pk col:test.t.a", + "Group#8 Schema:[test.t.a]", + " IndexScan_21 table:t, index:e_str, d_str, c_str", + "Group#9 Schema:[test.t.a]", + " IndexScan_19 table:t, index:c_str, d_str, e_str", + "Group#10 Schema:[test.t.a]", + " IndexScan_17 table:t, index:f, g", + "Group#11 Schema:[test.t.a]", + " IndexScan_15 table:t, index:g", + "Group#12 Schema:[test.t.a]", + " IndexScan_13 table:t, index:f", + "Group#13 Schema:[test.t.a]", + " IndexScan_11 table:t, index:c, d, e", + "Group#3 Schema:[Column#25]", + " Projection_7 input:[Group#14], test.t.b", + "Group#14 Schema:[test.t.b]", + " Projection_2 input:[Group#15], test.t.b", + "Group#15 Schema:[test.t.b]", + " Limit_25 input:[Group#16], offset:0, count:7", + "Group#16 Schema:[test.t.b]", + " TiKVSingleGather_24 input:[Group#17], table:t", + "Group#17 Schema:[test.t.b]", " TableScan_23 table:t" ] }, From bbf4e69c7678a4cde1e8686125d58405488ba8c2 Mon Sep 17 00:00:00 2001 From: Iosmanthus Teng Date: Tue, 31 Dec 2019 15:42:27 +0800 Subject: [PATCH 5/6] Forbid cast string as time Signed-off-by: Iosmanthus Teng --- expression/expr_to_pb.go | 1 + 1 file changed, 1 insertion(+) diff --git a/expression/expr_to_pb.go b/expression/expr_to_pb.go index 42b03d6dd290b..1fb1b686ba67a 100644 --- a/expression/expr_to_pb.go +++ b/expression/expr_to_pb.go @@ -468,6 +468,7 @@ func (pc PbConverter) canFuncBePushed(sf *ScalarFunction) bool { switch sf.Function.PbCode() { case tipb.ScalarFuncSig_CastStringAsInt, tipb.ScalarFuncSig_CastStringAsReal, + tipb.ScalarFuncSig_CastStringAsTime, tipb.ScalarFuncSig_CastTimeAsInt: return false default: From 721782d9c11f739b5b38901427803581634498ec Mon Sep 17 00:00:00 2001 From: Lonng Date: Tue, 31 Dec 2019 17:05:30 +0800 Subject: [PATCH 6/6] forbid json unquote push down Signed-off-by: Lonng --- expression/expr_to_pb.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/expression/expr_to_pb.go b/expression/expr_to_pb.go index 1fb1b686ba67a..7aa4c8ba06bbc 100644 --- a/expression/expr_to_pb.go +++ b/expression/expr_to_pb.go @@ -413,7 +413,8 @@ func (pc PbConverter) canFuncBePushed(sf *ScalarFunction) bool { // json functions. ast.JSONType, ast.JSONExtract, - ast.JSONUnquote, + // FIXME: JSONUnquote is incompatible with Coprocessor + // ast.JSONUnquote, ast.JSONObject, ast.JSONArray, ast.JSONMerge,