From 90ae7ccbb893525e49f5593073831dbab8953ed3 Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Tue, 12 Oct 2021 20:59:26 +0800 Subject: [PATCH] expression: limit valid decimal length (#28466) (#28647) --- expression/builtin_cast.go | 3 + planner/core/integration_test.go | 4 +- .../testdata/integration_serial_suite_in.json | 6 +- .../integration_serial_suite_out.json | 149 ++++++++++-------- 4 files changed, 92 insertions(+), 70 deletions(-) diff --git a/expression/builtin_cast.go b/expression/builtin_cast.go index f9fd1e512b4c3..7fac3ee46f4cc 100644 --- a/expression/builtin_cast.go +++ b/expression/builtin_cast.go @@ -1878,6 +1878,9 @@ func WrapWithCastAsDecimal(ctx sessionctx.Context, expr Expression) Expression { if expr.GetType().EvalType() == types.ETInt { tp.Flen = mysql.MaxIntWidth } + if tp.Flen == types.UnspecifiedLength || tp.Flen > mysql.MaxDecimalWidth { + tp.Flen = mysql.MaxDecimalWidth + } types.SetBinChsClnFlag(tp) tp.Flag |= expr.GetType().Flag & mysql.UnsignedFlag return BuildCastFunction(ctx, expr, tp) diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 707a8b23a0c05..87e8ecc390a88 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -3040,7 +3040,7 @@ func (s *testIntegrationSerialSuite) TestPushDownProjectionForTiFlash(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists t") - tk.MustExec("create table t (id int, value decimal(6,3))") + tk.MustExec("create table t (id int, value decimal(6,3), name char(128))") tk.MustExec("analyze table t") tk.MustExec("set session tidb_allow_mpp=OFF") @@ -3080,7 +3080,7 @@ func (s *testIntegrationSerialSuite) TestPushDownProjectionForMPP(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists t") - tk.MustExec("create table t (id int, value decimal(6,3))") + tk.MustExec("create table t (id int, value decimal(6,3), name char(128))") tk.MustExec("analyze table t") // Create virtual tiflash replica info. diff --git a/planner/core/testdata/integration_serial_suite_in.json b/planner/core/testdata/integration_serial_suite_in.json index 7bcff5de609cf..a613a9238f378 100644 --- a/planner/core/testdata/integration_serial_suite_in.json +++ b/planner/core/testdata/integration_serial_suite_in.json @@ -187,7 +187,8 @@ "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 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;" ] }, { @@ -206,7 +207,8 @@ "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 b*2, id from (select avg(value+2) as b, id from t group by id) C order by 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", + "desc format = 'brief' SELECT FROM_UNIXTIME(name,'%Y-%m-%d') FROM t;" ] }, { diff --git a/planner/core/testdata/integration_serial_suite_out.json b/planner/core/testdata/integration_serial_suite_out.json index 4ad5041a036ba..2893b00bb4407 100644 --- a/planner/core/testdata/integration_serial_suite_out.json +++ b/planner/core/testdata/integration_serial_suite_out.json @@ -1271,38 +1271,38 @@ { "SQL": "desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A", "Plan": [ - "HashAgg 1.00 root funcs:count(Column#7)->Column#5", + "HashAgg 1.00 root funcs:count(Column#8)->Column#6", "└─TableReader 1.00 root data:HashAgg", - " └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#4)->Column#7", - " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#4", + " └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#5)->Column#8", + " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#5", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, { "SQL": "desc format = 'brief' select /*+ hash_agg()*/ count(*) from (select id + 1 as b from t)A", "Plan": [ - "HashAgg 1.00 root funcs:count(Column#6)->Column#5", + "HashAgg 1.00 root funcs:count(Column#7)->Column#6", "└─TableReader 1.00 root data:HashAgg", - " └─HashAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#6", + " └─HashAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#7", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, { "SQL": "desc format = 'brief' select /*+ hash_agg()*/ sum(b) from (select id + 1 as b from t)A", "Plan": [ - "HashAgg 1.00 root funcs:sum(Column#7)->Column#5", + "HashAgg 1.00 root funcs:sum(Column#8)->Column#6", "└─TableReader 1.00 root data:HashAgg", - " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#8)->Column#7", - " └─Projection 10000.00 batchCop[tiflash] cast(Column#4, decimal(41,0) BINARY)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#4", + " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#9)->Column#8", + " └─Projection 10000.00 batchCop[tiflash] cast(Column#5, decimal(41,0) BINARY)->Column#9", + " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#5", " └─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#4)->Column#5", - "└─Projection 10000.00 root plus(test.t.id, 1)->Column#4", + "StreamAgg 1.00 root funcs:count(Column#5)->Column#6", + "└─Projection 10000.00 root plus(test.t.id, 1)->Column#5", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] @@ -1310,18 +1310,18 @@ { "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", + "StreamAgg 1.00 root funcs:count(Column#7)->Column#6", "└─TableReader 1.00 root data:StreamAgg", - " └─StreamAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#6", + " └─StreamAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#7", " └─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", - "└─Projection 10000.00 root cast(Column#4, decimal(41,0) BINARY)->Column#7", - " └─Projection 10000.00 root plus(test.t.id, 1)->Column#4", + "StreamAgg 1.00 root funcs:sum(Column#8)->Column#6", + "└─Projection 10000.00 root cast(Column#5, decimal(41,0) BINARY)->Column#8", + " └─Projection 10000.00 root plus(test.t.id, 1)->Column#5", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] @@ -1330,11 +1330,11 @@ "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", "Plan": [ "TableReader 10000.00 root data:HashJoin", - "└─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#4, Column#8)]", - " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#4", + "└─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#5, Column#10)]", + " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#5", " │ └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo, global read", - " └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#8", + " └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#10", " └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] @@ -1343,8 +1343,8 @@ "SQL": "desc format = 'brief' select * from t join (select id-2 as b from t) A on A.b=t.id", "Plan": [ "TableReader 10000.00 root data:HashJoin", - "└─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(test.t.id, Column#7)]", - " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#7", + "└─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(test.t.id, Column#9)]", + " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#9", " │ └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo, global read", " └─Selection(Probe) 9990.00 cop[tiflash] not(isnull(test.t.id))", @@ -1355,8 +1355,8 @@ "SQL": "desc format = 'brief' select * from t left join (select id-2 as b from t) A on A.b=t.id", "Plan": [ "TableReader 10000.00 root data:HashJoin", - "└─HashJoin 10000.00 cop[tiflash] left outer join, equal:[eq(test.t.id, Column#7)]", - " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#7", + "└─HashJoin 10000.00 cop[tiflash] left outer join, equal:[eq(test.t.id, Column#9)]", + " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#9", " │ └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo, global read", " └─TableFullScan(Probe) 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" @@ -1366,23 +1366,23 @@ "SQL": "desc format = 'brief' select * from t right join (select id-2 as b from t) A on A.b=t.id", "Plan": [ "TableReader 12487.50 root data:HashJoin", - "└─HashJoin 12487.50 cop[tiflash] right outer join, equal:[eq(test.t.id, Column#7)]", + "└─HashJoin 12487.50 cop[tiflash] right outer join, equal:[eq(test.t.id, Column#9)]", " ├─Selection(Build) 9990.00 cop[tiflash] not(isnull(test.t.id))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo, global read", - " └─Projection(Probe) 10000.00 cop[tiflash] minus(test.t.id, 2)->Column#7", + " └─Projection(Probe) 10000.00 cop[tiflash] minus(test.t.id, 2)->Column#9", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] }, { "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", + "Projection 10000.00 root Column#10, Column#5", "└─TableReader 10000.00 root data:HashJoin", - " └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#4, Column#8)]", - " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#4", + " └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#5, Column#10)]", + " ├─Projection(Build) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#5", " │ └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo, global read", - " └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#8", + " └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#10", " └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] @@ -1406,6 +1406,14 @@ " ├─TableFullScan(Build) 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo, global read", " └─TableFullScan(Probe) 10000.00 cop[tiflash] table:A keep order:false, stats:pseudo" ] + }, + { + "SQL": "desc format = 'brief' SELECT FROM_UNIXTIME(name,'%Y-%m-%d') FROM t;", + "Plan": [ + "Projection 10000.00 root from_unixtime(cast(test.t.name, decimal(65,0) BINARY), %Y-%m-%d)->Column#5", + "└─TableReader 10000.00 root data:TableFullScan", + " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" + ] } ] }, @@ -1415,66 +1423,66 @@ { "SQL": "desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A", "Plan": [ - "HashAgg 1.00 root funcs:count(Column#8)->Column#5", + "HashAgg 1.00 root funcs:count(Column#9)->Column#6", "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", - " └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#4)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#4", + " └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#5)->Column#9", + " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#5", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, { "SQL": "desc format = 'brief' select /*+ hash_agg()*/ count(*) from (select id + 1 as b from t)A", "Plan": [ - "HashAgg 1.00 root funcs:count(Column#7)->Column#5", + "HashAgg 1.00 root funcs:count(Column#8)->Column#6", "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", - " └─HashAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#7", + " └─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 /*+ hash_agg()*/ sum(b) from (select id + 1 as b from t)A", "Plan": [ - "HashAgg 1.00 root funcs:sum(Column#8)->Column#5", + "HashAgg 1.00 root funcs:sum(Column#9)->Column#6", "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", - " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#10)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] cast(Column#4, decimal(41,0) BINARY)->Column#10", - " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#4", + " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#11)->Column#9", + " └─Projection 10000.00 batchCop[tiflash] cast(Column#5, decimal(41,0) BINARY)->Column#11", + " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#5", " └─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": [ - "HashAgg 1.00 root funcs:count(Column#7)->Column#5", + "HashAgg 1.00 root funcs:count(Column#8)->Column#6", "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", - " └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#4)->Column#7", - " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#4", + " └─HashAgg 1.00 batchCop[tiflash] funcs:count(Column#5)->Column#8", + " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#5", " └─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": [ - "HashAgg 1.00 root funcs:count(Column#8)->Column#5", + "HashAgg 1.00 root funcs:count(Column#9)->Column#6", "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", - " └─HashAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#8", + " └─HashAgg 1.00 batchCop[tiflash] funcs:count(1)->Column#9", " └─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": [ - "HashAgg 1.00 root funcs:sum(Column#7)->Column#5", + "HashAgg 1.00 root funcs:sum(Column#8)->Column#6", "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", - " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#8)->Column#7", - " └─Projection 10000.00 batchCop[tiflash] cast(Column#4, decimal(41,0) BINARY)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#4", + " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#9)->Column#8", + " └─Projection 10000.00 batchCop[tiflash] cast(Column#5, decimal(41,0) BINARY)->Column#9", + " └─Projection 10000.00 batchCop[tiflash] plus(test.t.id, 1)->Column#5", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, @@ -1483,14 +1491,14 @@ "Plan": [ "TableReader 10000.00 root data:ExchangeSender", "└─ExchangeSender 10000.00 cop[tiflash] ExchangeType: PassThrough", - " └─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)]", + " └─Projection 10000.00 cop[tiflash] plus(Column#5, Column#10)->Column#11", + " └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#5, Column#10)]", " ├─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", + " │ └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#5", " │ └─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", + " └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#10", " └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] @@ -1500,10 +1508,10 @@ "Plan": [ "TableReader 10000.00 root data:ExchangeSender", "└─ExchangeSender 10000.00 cop[tiflash] ExchangeType: PassThrough", - " └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(test.t.id, Column#7)]", + " └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(test.t.id, Column#9)]", " ├─ExchangeReceiver(Build) 8000.00 cop[tiflash] ", " │ └─ExchangeSender 8000.00 cop[tiflash] ExchangeType: Broadcast", - " │ └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#7", + " │ └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#9", " │ └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo", " └─Selection(Probe) 9990.00 cop[tiflash] not(isnull(test.t.id))", @@ -1515,10 +1523,10 @@ "Plan": [ "TableReader 10000.00 root data:ExchangeSender", "└─ExchangeSender 10000.00 cop[tiflash] ExchangeType: PassThrough", - " └─HashJoin 10000.00 cop[tiflash] left outer join, equal:[eq(test.t.id, Column#7)]", + " └─HashJoin 10000.00 cop[tiflash] left outer join, equal:[eq(test.t.id, Column#9)]", " ├─ExchangeReceiver(Build) 8000.00 cop[tiflash] ", " │ └─ExchangeSender 8000.00 cop[tiflash] ExchangeType: Broadcast", - " │ └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#7", + " │ └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#9", " │ └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo", " └─TableFullScan(Probe) 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" @@ -1529,12 +1537,12 @@ "Plan": [ "TableReader 12487.50 root data:ExchangeSender", "└─ExchangeSender 12487.50 cop[tiflash] ExchangeType: PassThrough", - " └─HashJoin 12487.50 cop[tiflash] right outer join, equal:[eq(test.t.id, Column#7)]", + " └─HashJoin 12487.50 cop[tiflash] right outer join, equal:[eq(test.t.id, Column#9)]", " ├─ExchangeReceiver(Build) 9990.00 cop[tiflash] ", " │ └─ExchangeSender 9990.00 cop[tiflash] ExchangeType: Broadcast", " │ └─Selection 9990.00 cop[tiflash] not(isnull(test.t.id))", " │ └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo", - " └─Projection(Probe) 10000.00 cop[tiflash] minus(test.t.id, 2)->Column#7", + " └─Projection(Probe) 10000.00 cop[tiflash] minus(test.t.id, 2)->Column#9", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] }, @@ -1543,14 +1551,14 @@ "Plan": [ "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)]", + " └─Projection 10000.00 cop[tiflash] Column#10, Column#5", + " └─HashJoin 10000.00 cop[tiflash] inner join, equal:[eq(Column#5, Column#10)]", " ├─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", + " │ └─Projection 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#5", " │ └─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", + " └─Projection(Probe) 8000.00 cop[tiflash] minus(test.t.id, 2)->Column#10", " └─Selection 8000.00 cop[tiflash] not(isnull(minus(test.t.id, 2)))", " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ] @@ -1587,15 +1595,24 @@ "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", + " └─Projection 8000.00 batchCop[tiflash] mul(Column#5, 2)->Column#6, test.t.id", + " └─Projection 8000.00 batchCop[tiflash] div(Column#5, cast(case(eq(Column#20, 0), 1, Column#20), decimal(20,0) BINARY))->Column#5, test.t.id", + " └─HashAgg 8000.00 batchCop[tiflash] group by:test.t.id, funcs:sum(Column#21)->Column#20, funcs:sum(Column#22)->Column#5, 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", + " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#26, funcs:count(Column#24)->Column#21, funcs:sum(Column#25)->Column#22", + " └─Projection 10000.00 batchCop[tiflash] plus(test.t.value, 2)->Column#24, plus(test.t.value, 2)->Column#25, test.t.id", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] + }, + { + "SQL": "desc format = 'brief' SELECT FROM_UNIXTIME(name,'%Y-%m-%d') FROM t;", + "Plan": [ + "TableReader 10000.00 root data:ExchangeSender", + "└─ExchangeSender 10000.00 cop[tiflash] ExchangeType: PassThrough", + " └─Projection 10000.00 cop[tiflash] from_unixtime(cast(test.t.name, decimal(65,0) BINARY), %Y-%m-%d)->Column#5", + " └─TableFullScan 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" + ] } ] },