diff --git a/cmd/explaintest/r/explain_complex.result b/cmd/explaintest/r/explain_complex.result index b3c79948a142e..43f7c0f915f14 100644 --- a/cmd/explaintest/r/explain_complex.result +++ b/cmd/explaintest/r/explain_complex.result @@ -182,7 +182,7 @@ CREATE TABLE `tbl_009` (`a` int, `b` int); explain format = 'brief' select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b; id estRows task access object operator info HashAgg 72000.00 root group by:Column#32, funcs:sum(Column#31)->Column#30 -└─Projection 90000.00 root cast(Column#28, decimal(32,0) BINARY)->Column#31, Column#29 +└─Projection 90000.00 root cast(Column#28, decimal(10,0) BINARY)->Column#31, Column#29 └─Union 90000.00 root ├─TableReader 10000.00 root data:TableFullScan │ └─TableFullScan 10000.00 cop[tikv] table:tbl_001 keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/explain_complex_stats.result b/cmd/explaintest/r/explain_complex_stats.result index 4365be0c45336..ed7021dbbfba2 100644 --- a/cmd/explaintest/r/explain_complex_stats.result +++ b/cmd/explaintest/r/explain_complex_stats.result @@ -205,7 +205,7 @@ load stats 's/explain_complex_stats_tbl_009.json'; explain format = 'brief' select sum(a) from (select * from tbl_001 union all select * from tbl_002 union all select * from tbl_003 union all select * from tbl_004 union all select * from tbl_005 union all select * from tbl_006 union all select * from tbl_007 union all select * from tbl_008 union all select * from tbl_009) x group by b; id estRows task access object operator info HashAgg 18000.00 root group by:Column#32, funcs:sum(Column#31)->Column#30 -└─Projection 18000.00 root cast(Column#28, decimal(32,0) BINARY)->Column#31, Column#29 +└─Projection 18000.00 root cast(Column#28, decimal(10,0) BINARY)->Column#31, Column#29 └─Union 18000.00 root ├─TableReader 2000.00 root data:TableFullScan │ └─TableFullScan 2000.00 cop[tikv] table:tbl_001 keep order:false diff --git a/cmd/explaintest/r/explain_easy.result b/cmd/explaintest/r/explain_easy.result index 2eec1954d46df..3eb32472170e5 100644 --- a/cmd/explaintest/r/explain_easy.result +++ b/cmd/explaintest/r/explain_easy.result @@ -91,7 +91,7 @@ Selection 0.33 root gt(test.t1.c2, 1) explain format = 'brief' select sum(t1.c1 in (select c1 from t2)) from t1; id estRows task access object operator info StreamAgg 1.00 root funcs:sum(Column#13)->Column#11 -└─Projection 10000.00 root cast(Column#10, decimal(65,0) BINARY)->Column#13 +└─Projection 10000.00 root cast(Column#10, decimal(3,0) BINARY)->Column#13 └─HashJoin 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) ├─IndexReader(Build) 10000.00 root index:IndexFullScan │ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo @@ -225,7 +225,7 @@ set @@session.tidb_opt_insubq_to_join_and_agg=0; explain format = 'brief' select sum(t1.c1 in (select c1 from t2)) from t1; id estRows task access object operator info StreamAgg 1.00 root funcs:sum(Column#13)->Column#11 -└─Projection 10000.00 root cast(Column#10, decimal(65,0) BINARY)->Column#13 +└─Projection 10000.00 root cast(Column#10, decimal(3,0) BINARY)->Column#13 └─HashJoin 10000.00 root CARTESIAN left outer semi join, other cond:eq(test.t1.c1, test.t2.c1) ├─IndexReader(Build) 10000.00 root index:IndexFullScan │ └─IndexFullScan 10000.00 cop[tikv] table:t2, index:c1(c1) keep order:false, stats:pseudo @@ -241,7 +241,7 @@ HashJoin 10000.00 root CARTESIAN left outer semi join, other cond:eq(1, test.t2 explain format = 'brief' select sum(6 in (select c2 from t2)) from t1; id estRows task access object operator info StreamAgg 1.00 root funcs:sum(Column#13)->Column#11 -└─Projection 10000.00 root cast(Column#10, decimal(65,0) BINARY)->Column#13 +└─Projection 10000.00 root cast(Column#10, decimal(3,0) BINARY)->Column#13 └─HashJoin 10000.00 root CARTESIAN left outer semi join, other cond:eq(6, test.t2.c2) ├─TableReader(Build) 10000.00 root data:TableFullScan │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo @@ -809,7 +809,7 @@ Projection 1.00 root Column#7 └─HashAgg(Probe) 1.00 root funcs:sum(Column#12)->Column#7 └─HashJoin 1.00 root CARTESIAN left outer join ├─HashAgg(Build) 1.00 root group by:1, funcs:sum(Column#14)->Column#12 - │ └─Projection 1.00 root cast(Column#6, decimal(42,0) BINARY)->Column#14 + │ └─Projection 1.00 root cast(Column#6, decimal(20,0) BINARY)->Column#14 │ └─MaxOneRow 1.00 root │ └─Projection 1.00 root Column#5 │ └─TableDual 1.00 root rows:1 @@ -831,7 +831,7 @@ Projection 1.00 root Column#5 │ └─TableReader 10000.00 root data:TableFullScan │ └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo └─StreamAgg(Probe) 1.00 root funcs:sum(Column#7)->Column#5 - └─Projection 1.00 root cast(Column#4, decimal(42,0) BINARY)->Column#7 + └─Projection 1.00 root cast(Column#4, decimal(20,0) BINARY)->Column#7 └─TableDual 1.00 root rows:1 explain format = 'brief' select sum(a), (select sum(a)), count(a) from t group by b order by (select count(a)); id estRows task access object operator info @@ -846,3 +846,121 @@ Projection 8000.00 root Column#4, Column#4, Column#5 └─HashAgg 8000.00 cop[tikv] group by:test.t.b, funcs:sum(test.t.a)->Column#13, funcs:count(test.t.a)->Column#14 └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo drop table if exists t; +create table t(a tinyint, b smallint, c mediumint, d int, e bigint); +insert into mysql.opt_rule_blacklist VALUES("aggregation_push_down"); +admin reload opt_rule_blacklist; + +explain format = 'brief' select sum(t1.a) from t t1 join t t2 on t1.a=t2.a; +id estRows task access object operator info +StreamAgg 1.00 root funcs:sum(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.a, decimal(3,0) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.a, test.t.a)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.a)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.a)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select sum(t1.b) from t t1 join t t2 on t1.b=t2.b; +id estRows task access object operator info +StreamAgg 1.00 root funcs:sum(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.b, decimal(5,0) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.b, test.t.b)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.b)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select sum(t1.c) from t t1 join t t2 on t1.c=t2.c; +id estRows task access object operator info +StreamAgg 1.00 root funcs:sum(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.c, decimal(8,0) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.c, test.t.c)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.c)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.c)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select sum(t1.d) from t t1 join t t2 on t1.d=t2.d; +id estRows task access object operator info +StreamAgg 1.00 root funcs:sum(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.d, decimal(10,0) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.d, test.t.d)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.d)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.d)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select sum(t1.e) from t t1 join t t2 on t1.e=t2.e; +id estRows task access object operator info +StreamAgg 1.00 root funcs:sum(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.e, decimal(20,0) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.e, test.t.e)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.e)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.e)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select avg(t1.a) from t t1 join t t2 on t1.a=t2.a; +id estRows task access object operator info +StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.a, decimal(8,4) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.a, test.t.a)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.a)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.a)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select avg(t1.b) from t t1 join t t2 on t1.b=t2.b; +id estRows task access object operator info +StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.b, decimal(10,4) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.b, test.t.b)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.b)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.b)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select avg(t1.c) from t t1 join t t2 on t1.c=t2.c; +id estRows task access object operator info +StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.c, decimal(13,4) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.c, test.t.c)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.c)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.c)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select avg(t1.d) from t t1 join t t2 on t1.d=t2.d; +id estRows task access object operator info +StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.d, decimal(15,4) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.d, test.t.d)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.d)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.d)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +explain format = 'brief' select avg(t1.e) from t t1 join t t2 on t1.e=t2.e; +id estRows task access object operator info +StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 +└─Projection 12487.50 root cast(test.t.e, decimal(24,4) BINARY)->Column#14 + └─HashJoin 12487.50 root inner join, equal:[eq(test.t.e, test.t.e)] + ├─TableReader(Build) 9990.00 root data:Selection + │ └─Selection 9990.00 cop[tikv] not(isnull(test.t.e)) + │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo + └─TableReader(Probe) 9990.00 root data:Selection + └─Selection 9990.00 cop[tikv] not(isnull(test.t.e)) + └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo +drop table if exists t; +delete from mysql.opt_rule_blacklist where name="aggregation_push_down"; +admin reload opt_rule_blacklist; + diff --git a/cmd/explaintest/r/generated_columns.result b/cmd/explaintest/r/generated_columns.result index d7f120eb28f3f..970f00880ac5d 100644 --- a/cmd/explaintest/r/generated_columns.result +++ b/cmd/explaintest/r/generated_columns.result @@ -182,7 +182,7 @@ INSERT INTO t1 (a) VALUES (2), (1), (1), (3), (NULL); EXPLAIN format = 'brief' SELECT sum(a) FROM t1 GROUP BY b; id estRows task access object operator info HashAgg 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 -└─Projection 10000.00 root cast(test.t1.a, decimal(32,0) BINARY)->Column#6, test.t1.b +└─Projection 10000.00 root cast(test.t1.a, decimal(10,0) BINARY)->Column#6, test.t1.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN format = 'brief' SELECT sum(a) FROM t1 GROUP BY c; @@ -194,13 +194,13 @@ HashAgg 8000.00 root group by:test.t1.c, funcs:sum(Column#6)->Column#5 EXPLAIN format = 'brief' SELECT sum(b) FROM t1 GROUP BY a; id estRows task access object operator info HashAgg 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 -└─Projection 10000.00 root cast(test.t1.b, decimal(32,0) BINARY)->Column#6, test.t1.a +└─Projection 10000.00 root cast(test.t1.b, decimal(10,0) BINARY)->Column#6, test.t1.a └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo EXPLAIN format = 'brief' SELECT sum(b) FROM t1 GROUP BY c; id estRows task access object operator info HashAgg 8000.00 root group by:Column#9, funcs:sum(Column#8)->Column#5 -└─Projection 10000.00 root cast(test.t1.b, decimal(32,0) BINARY)->Column#8, test.t1.c +└─Projection 10000.00 root cast(test.t1.b, decimal(10,0) BINARY)->Column#8, test.t1.c └─Projection 10000.00 root test.t1.b, test.t1.c └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo @@ -213,7 +213,7 @@ HashAgg 8000.00 root group by:test.t1.a, funcs:sum(Column#6)->Column#5 EXPLAIN format = 'brief' SELECT sum(c) FROM t1 GROUP BY b; id estRows task access object operator info HashAgg 8000.00 root group by:Column#7, funcs:sum(Column#6)->Column#5 -└─Projection 10000.00 root cast(test.t1.c, decimal(32,0) BINARY)->Column#6, test.t1.b +└─Projection 10000.00 root cast(test.t1.c, decimal(10,0) BINARY)->Column#6, test.t1.b └─Projection 10000.00 root test.t1.b, test.t1.c └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/index_merge.result b/cmd/explaintest/r/index_merge.result index 261acdb49d8a2..f4d6571fd8fe3 100644 --- a/cmd/explaintest/r/index_merge.result +++ b/cmd/explaintest/r/index_merge.result @@ -481,7 +481,7 @@ explain select /*+ use_index_merge(t1) */ sum(c1) from t1 where (c1 < 10 or c2 < id estRows task access object operator info Sort_6 1473.49 root Column#5 └─HashAgg_11 1473.49 root group by:Column#10, funcs:sum(Column#9)->Column#5 - └─Projection_18 1841.86 root cast(test.t1.c1, decimal(32,0) BINARY)->Column#9, test.t1.c1 + └─Projection_18 1841.86 root cast(test.t1.c1, decimal(10,0) BINARY)->Column#9, test.t1.c1 └─IndexMerge_16 1841.86 root ├─IndexRangeScan_12(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo ├─IndexRangeScan_13(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/select.result b/cmd/explaintest/r/select.result index 959e761aad086..f364a577e1071 100644 --- a/cmd/explaintest/r/select.result +++ b/cmd/explaintest/r/select.result @@ -385,7 +385,7 @@ id estRows task access object operator info Projection 10000.00 root and(or(or(gt(Column#11, 1), ne(test.t.a, Column#10)), if(ne(Column#12, 0), , 0)), and(ne(Column#13, 0), if(isnull(test.t.a), , 1)))->Column#14 └─HashJoin 10000.00 root CARTESIAN inner join ├─StreamAgg(Build) 1.00 root funcs:max(Column#16)->Column#10, funcs:count(distinct Column#17)->Column#11, funcs:sum(Column#18)->Column#12, funcs:count(1)->Column#13 - │ └─Projection 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(22,0) BINARY)->Column#18 + │ └─Projection 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(20,0) BINARY)->Column#18 │ └─TableReader 10000.00 root data:TableFullScan │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo └─TableReader(Probe) 10000.00 root data:TableFullScan @@ -395,7 +395,7 @@ id estRows task access object operator info Projection 10000.00 root or(and(and(le(Column#11, 1), eq(test.t.a, Column#10)), if(ne(Column#12, 0), , 1)), or(eq(Column#13, 0), if(isnull(test.t.a), , 0)))->Column#14 └─HashJoin 10000.00 root CARTESIAN inner join ├─StreamAgg(Build) 1.00 root funcs:firstrow(Column#16)->Column#10, funcs:count(distinct Column#17)->Column#11, funcs:sum(Column#18)->Column#12, funcs:count(1)->Column#13 - │ └─Projection 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(22,0) BINARY)->Column#18 + │ └─Projection 10000.00 root test.t.a, test.t.a, cast(isnull(test.t.a), decimal(20,0) BINARY)->Column#18 │ └─TableReader 10000.00 root data:TableFullScan │ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo └─TableReader(Probe) 10000.00 root data:TableFullScan diff --git a/cmd/explaintest/r/tpch.result b/cmd/explaintest/r/tpch.result index 319713d946aa2..c9edd22189514 100644 --- a/cmd/explaintest/r/tpch.result +++ b/cmd/explaintest/r/tpch.result @@ -773,7 +773,7 @@ id estRows task access object operator info Sort 1.00 root tpch.lineitem.l_shipmode └─Projection 1.00 root tpch.lineitem.l_shipmode, Column#27, Column#28 └─HashAgg 1.00 root group by:Column#40, funcs:sum(Column#37)->Column#27, funcs:sum(Column#38)->Column#28, funcs:firstrow(Column#39)->tpch.lineitem.l_shipmode - └─Projection 10023369.01 root cast(case(or(eq(tpch.orders.o_orderpriority, 1-URGENT), eq(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(22,0) BINARY)->Column#37, cast(case(and(ne(tpch.orders.o_orderpriority, 1-URGENT), ne(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(22,0) BINARY)->Column#38, tpch.lineitem.l_shipmode, tpch.lineitem.l_shipmode + └─Projection 10023369.01 root cast(case(or(eq(tpch.orders.o_orderpriority, 1-URGENT), eq(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(20,0) BINARY)->Column#37, cast(case(and(ne(tpch.orders.o_orderpriority, 1-URGENT), ne(tpch.orders.o_orderpriority, 2-HIGH)), 1, 0), decimal(20,0) BINARY)->Column#38, tpch.lineitem.l_shipmode, tpch.lineitem.l_shipmode └─Projection 10023369.01 root tpch.orders.o_orderpriority, tpch.lineitem.l_shipmode └─IndexJoin 10023369.01 root inner join, inner:TableReader, outer key:tpch.lineitem.l_orderkey, inner key:tpch.orders.o_orderkey, equal cond:eq(tpch.lineitem.l_orderkey, tpch.orders.o_orderkey) ├─TableReader(Build) 10023369.01 root data:Selection diff --git a/cmd/explaintest/r/window_function.result b/cmd/explaintest/r/window_function.result index 6c92b63dcd0d3..b29d1e5d3fba7 100644 --- a/cmd/explaintest/r/window_function.result +++ b/cmd/explaintest/r/window_function.result @@ -6,47 +6,47 @@ set @@session.tidb_window_concurrency = 1; explain format = 'brief' select sum(a) over() from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over() +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over() └─IndexReader 10000.00 root index:IndexFullScan └─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(a) keep order:false, stats:pseudo explain format = 'brief' select sum(a) over(partition by a) from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a) +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a) └─IndexReader 10000.00 root index:IndexFullScan └─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(a) keep order:true, stats:pseudo explain format = 'brief' select sum(a) over(partition by a order by b) from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row) +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain format = 'brief' select sum(a) over(partition by a order by b rows unbounded preceding) from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between unbounded preceding and current row) +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between unbounded preceding and current row) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain format = 'brief' select sum(a) over(partition by a order by b rows between 1 preceding and 1 following) from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between 1 preceding and 1 following) +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between 1 preceding and 1 following) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain format = 'brief' select sum(a) over(partition by a order by b range between 1 preceding and 1 following) from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between 1 preceding and 1 following) +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between 1 preceding and 1 following) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo explain format = 'brief' select sum(a) over(partition by a order by c range between interval '2:30' minute_second preceding and interval '2:30' minute_second following) from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) └─Sort 10000.00 root test.t.a, test.t.c └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -54,20 +54,20 @@ set @@session.tidb_window_concurrency = 4; explain format = 'brief' select sum(a) over() from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over() +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over() └─IndexReader 10000.00 root index:IndexFullScan └─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(a) keep order:false, stats:pseudo explain format = 'brief' select sum(a) over(partition by a) from t; id estRows task access object operator info Projection 10000.00 root Column#6 -└─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a) +└─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a) └─IndexReader 10000.00 root index:IndexFullScan └─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(a) keep order:true, stats:pseudo explain format = 'brief' select sum(a) over(partition by a order by b) from t; id estRows task access object operator info Projection 10000.00 root Column#6 └─Shuffle 10000.00 root execution info: concurrency:4, data sources:[TableReader] - └─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row) + └─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -75,7 +75,7 @@ explain format = 'brief' select sum(a) over(partition by a order by b rows unbou id estRows task access object operator info Projection 10000.00 root Column#6 └─Shuffle 10000.00 root execution info: concurrency:4, data sources:[TableReader] - └─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between unbounded preceding and current row) + └─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between unbounded preceding and current row) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -83,7 +83,7 @@ explain format = 'brief' select sum(a) over(partition by a order by b rows betwe id estRows task access object operator info Projection 10000.00 root Column#6 └─Shuffle 10000.00 root execution info: concurrency:4, data sources:[TableReader] - └─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between 1 preceding and 1 following) + └─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b rows between 1 preceding and 1 following) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -91,7 +91,7 @@ explain format = 'brief' select sum(a) over(partition by a order by b range betw id estRows task access object operator info Projection 10000.00 root Column#6 └─Shuffle 10000.00 root execution info: concurrency:4, data sources:[TableReader] - └─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between 1 preceding and 1 following) + └─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.b range between 1 preceding and 1 following) └─Sort 10000.00 root test.t.a, test.t.b └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -99,7 +99,7 @@ explain format = 'brief' select sum(a) over(partition by a order by c range betw id estRows task access object operator info Projection 10000.00 root Column#6 └─Shuffle 10000.00 root execution info: concurrency:4, data sources:[TableReader] - └─Window 10000.00 root sum(cast(test.t.a, decimal(32,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) + └─Window 10000.00 root sum(cast(test.t.a, decimal(10,0) BINARY))->Column#6 over(partition by test.t.a order by test.t.c range between interval "2:30" "MINUTE_SECOND" preceding and interval "2:30" "MINUTE_SECOND" following) └─Sort 10000.00 root test.t.a, test.t.c └─TableReader 10000.00 root data:TableFullScan └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -110,7 +110,7 @@ analyze table t1; explain format = 'brief' select sum(a) over(partition by b) from t1; id estRows task access object operator info Projection 2.00 root Column#4 -└─Window 2.00 root sum(cast(test.t1.a, decimal(32,0) BINARY))->Column#4 over(partition by test.t1.b) +└─Window 2.00 root sum(cast(test.t1.a, decimal(10,0) BINARY))->Column#4 over(partition by test.t1.b) └─Sort 2.00 root test.t1.b └─TableReader 2.00 root data:TableFullScan └─TableFullScan 2.00 cop[tikv] table:t1 keep order:false @@ -120,7 +120,7 @@ explain format = 'brief' select sum(a) over(partition by b) from t1; id estRows task access object operator info Projection 3.00 root Column#4 └─Shuffle 3.00 root execution info: concurrency:2, data sources:[TableReader] - └─Window 3.00 root sum(cast(test.t1.a, decimal(32,0) BINARY))->Column#4 over(partition by test.t1.b) + └─Window 3.00 root sum(cast(test.t1.a, decimal(10,0) BINARY))->Column#4 over(partition by test.t1.b) └─Sort 3.00 root test.t1.b └─TableReader 3.00 root data:TableFullScan └─TableFullScan 3.00 cop[tikv] table:t1 keep order:false diff --git a/cmd/explaintest/t/explain_easy.test b/cmd/explaintest/t/explain_easy.test index 4d3b698bd7d72..161b716f5a666 100644 --- a/cmd/explaintest/t/explain_easy.test +++ b/cmd/explaintest/t/explain_easy.test @@ -218,3 +218,22 @@ explain format = 'brief' select count(a) from t group by b order by (select coun explain format = 'brief' select (select sum(count(a))) from t; explain format = 'brief' select sum(a), (select sum(a)), count(a) from t group by b order by (select count(a)); drop table if exists t; + +# lower precision for cast to decimal for integer type variables in sum function +create table t(a tinyint, b smallint, c mediumint, d int, e bigint); +insert into mysql.opt_rule_blacklist VALUES("aggregation_push_down"); +admin reload opt_rule_blacklist; +explain format = 'brief' select sum(t1.a) from t t1 join t t2 on t1.a=t2.a; +explain format = 'brief' select sum(t1.b) from t t1 join t t2 on t1.b=t2.b; +explain format = 'brief' select sum(t1.c) from t t1 join t t2 on t1.c=t2.c; +explain format = 'brief' select sum(t1.d) from t t1 join t t2 on t1.d=t2.d; +explain format = 'brief' select sum(t1.e) from t t1 join t t2 on t1.e=t2.e; +# note that avg will be converted to count and sum, and .decimal field will be non-zero +explain format = 'brief' select avg(t1.a) from t t1 join t t2 on t1.a=t2.a; +explain format = 'brief' select avg(t1.b) from t t1 join t t2 on t1.b=t2.b; +explain format = 'brief' select avg(t1.c) from t t1 join t t2 on t1.c=t2.c; +explain format = 'brief' select avg(t1.d) from t t1 join t t2 on t1.d=t2.d; +explain format = 'brief' select avg(t1.e) from t t1 join t t2 on t1.e=t2.e; +drop table if exists t; +delete from mysql.opt_rule_blacklist where name="aggregation_push_down"; +admin reload opt_rule_blacklist; diff --git a/executor/testdata/agg_suite_out.json b/executor/testdata/agg_suite_out.json index abfb0f9d102ef..1937b7f4cc358 100644 --- a/executor/testdata/agg_suite_out.json +++ b/executor/testdata/agg_suite_out.json @@ -54,7 +54,7 @@ " ├─Apply(Build) 1.00 root CARTESIAN left outer join", " │ ├─Apply(Build) 1.00 root CARTESIAN left outer join", " │ │ ├─HashAgg(Build) 1.00 root funcs:sum(Column#28)->Column#9, funcs:firstrow(Column#29)->test.test.a", - " │ │ │ └─Projection 10000.00 root cast(test.test.a, decimal(32,0) BINARY)->Column#28, test.test.a", + " │ │ │ └─Projection 10000.00 root cast(test.test.a, decimal(10,0) BINARY)->Column#28, test.test.a", " │ │ │ └─TableReader 10000.00 root data:TableFullScan", " │ │ │ └─TableFullScan 10000.00 cop[tikv] table:tt keep order:false, stats:pseudo", " │ │ └─Projection(Probe) 1.00 root ->Column#12", diff --git a/expression/aggregation/base_func.go b/expression/aggregation/base_func.go index 1c639eeb4f14d..a185910c82b97 100644 --- a/expression/aggregation/base_func.go +++ b/expression/aggregation/base_func.go @@ -178,7 +178,7 @@ func (a *baseFuncDesc) typeInfer4ApproxPercentile(ctx sessionctx.Context) error return nil } -// typeInfer4Sum should returns a "decimal", otherwise it returns a "double". +// typeInfer4Sum should return a "decimal", otherwise it returns a "double". // Because child returns integer or decimal type. func (a *baseFuncDesc) typeInfer4Sum(ctx sessionctx.Context) { switch a.Args[0].GetType().Tp { @@ -421,6 +421,7 @@ func (a *baseFuncDesc) WrapCastForAggArgs(ctx sessionctx.Context) { if a.Args[i].GetType().Tp == mysql.TypeNull { continue } + tpOld := a.Args[i].GetType().Tp a.Args[i] = castFunc(ctx, a.Args[i]) if a.Name != ast.AggFuncAvg && a.Name != ast.AggFuncSum { continue @@ -443,5 +444,37 @@ func (a *baseFuncDesc) WrapCastForAggArgs(ctx sessionctx.Context) { originTp := a.Args[i].GetType().Tp *(a.Args[i].GetType()) = *(a.RetTp) a.Args[i].GetType().Tp = originTp + + // refine each mysql integer type to the needed decimal precision for sum + if a.Name == ast.AggFuncSum { + adjustDecimalLenForSumInteger(a.Args[i].GetType(), tpOld) + } + } +} + +func adjustDecimalLenForSumInteger(ft *types.FieldType, tpOld byte) { + if types.IsTypeInteger(tpOld) && ft.Tp == mysql.TypeNewDecimal { + if flen, err := minimalDecimalLenForHoldingInteger(tpOld); err == nil { + ft.Flen = mathutil.Min(ft.Flen, flen+ft.Decimal) + } + } +} + +func minimalDecimalLenForHoldingInteger(tp byte) (int, error) { + switch tp { + case mysql.TypeTiny: + return 3, nil + case mysql.TypeShort: + return 5, nil + case mysql.TypeInt24: + return 8, nil + case mysql.TypeLong: + return 10, nil + case mysql.TypeLonglong: + return 20, nil + case mysql.TypeYear: + return 4, nil + default: + return -1, errors.Errorf("Invalid type: %v", tp) } } diff --git a/expression/builtin.go b/expression/builtin.go index 1b67239613498..71fde7647a598 100644 --- a/expression/builtin.go +++ b/expression/builtin.go @@ -114,7 +114,7 @@ func newBaseBuiltinFunc(ctx sessionctx.Context, funcName string, args []Expressi // newBaseBuiltinFuncWithTp creates a built-in function signature with specified types of arguments and the return type of the function. // argTps indicates the types of the args, retType indicates the return type of the built-in function. -// Every built-in function needs determined argTps and retType when we create it. +// Every built-in function needs to be determined argTps and retType when we create it. func newBaseBuiltinFuncWithTp(ctx sessionctx.Context, funcName string, args []Expression, retType types.EvalType, argTps ...types.EvalType) (bf baseBuiltinFunc, err error) { if len(args) != len(argTps) { panic("unexpected length of args and argTps") diff --git a/parser/mysql/type.go b/parser/mysql/type.go index be030bd9c81d3..c54d0f8984b63 100644 --- a/parser/mysql/type.go +++ b/parser/mysql/type.go @@ -16,15 +16,15 @@ package mysql // MySQL type information. const ( TypeUnspecified byte = 0 - TypeTiny byte = 1 - TypeShort byte = 2 - TypeLong byte = 3 + TypeTiny byte = 1 // TINYINT + TypeShort byte = 2 // SMALLINT + TypeLong byte = 3 // INT TypeFloat byte = 4 TypeDouble byte = 5 TypeNull byte = 6 TypeTimestamp byte = 7 - TypeLonglong byte = 8 - TypeInt24 byte = 9 + TypeLonglong byte = 8 // BIGINT + TypeInt24 byte = 9 // MEDIUMINT TypeDate byte = 10 /* TypeDuration original name was TypeTime, renamed to TypeDuration to resolve the conflict with Go type Time.*/ TypeDuration byte = 11 diff --git a/planner/cascades/testdata/integration_suite_out.json b/planner/cascades/testdata/integration_suite_out.json index 3b2719c02d293..21b601bfc9198 100644 --- a/planner/cascades/testdata/integration_suite_out.json +++ b/planner/cascades/testdata/integration_suite_out.json @@ -197,7 +197,7 @@ " └─Sort_29 6400.00 root test.t.b", " └─Selection_28 6400.00 root gt(Column#4, 1)", " └─HashAgg_19 8000.00 root group by:test.t.b, funcs:avg(Column#11)->Column#3, funcs:sum(Column#12)->Column#4, funcs:firstrow(test.t.b)->test.t.b", - " └─Projection_20 10000.00 root cast(test.t.a, decimal(15,4) BINARY)->Column#11, cast(test.t.a, decimal(32,0) BINARY)->Column#12, test.t.b, test.t.b", + " └─Projection_20 10000.00 root cast(test.t.a, decimal(15,4) BINARY)->Column#11, cast(test.t.a, decimal(10,0) BINARY)->Column#12, test.t.b, test.t.b", " └─TableReader_21 10000.00 root data:TableFullScan_22", " └─TableFullScan_22 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], @@ -636,7 +636,7 @@ "Plan": [ "Projection_8 8000.00 root Column#5, test.t.c, Column#5, Column#6, Column#7, Column#8, Column#9", "└─HashAgg_9 8000.00 root group by:test.t.c, funcs:avg(Column#10)->Column#5, funcs:count(distinct test.t.a, test.t.b)->Column#6, funcs:count(distinct test.t.a)->Column#7, funcs:count(distinct test.t.c)->Column#8, funcs:sum(Column#11)->Column#9, funcs:firstrow(test.t.c)->test.t.c", - " └─Projection_10 10000.00 root cast(test.t.b, decimal(15,4) BINARY)->Column#10, test.t.a, test.t.b, test.t.a, test.t.c, cast(test.t.b, decimal(32,0) BINARY)->Column#11, test.t.c, test.t.c", + " └─Projection_10 10000.00 root cast(test.t.b, decimal(15,4) BINARY)->Column#10, test.t.a, test.t.b, test.t.a, test.t.c, cast(test.t.b, decimal(10,0) BINARY)->Column#11, test.t.c, test.t.c", " └─TableReader_11 10000.00 root data:TableFullScan_12", " └─TableFullScan_12 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], diff --git a/planner/core/preprocess.go b/planner/core/preprocess.go index 6e2f9aaed4f53..7eb2a3c041c52 100644 --- a/planner/core/preprocess.go +++ b/planner/core/preprocess.go @@ -109,7 +109,7 @@ func TryAddExtraLimit(ctx sessionctx.Context, node ast.StmtNode) ast.StmtNode { return node } -// Preprocess resolves table names of the node, and checks some statements validation. +// Preprocess resolves table names of the node, and checks some statements' validation. // preprocessReturn used to extract the infoschema for the tableName and the timestamp from the asof clause. func Preprocess(ctx sessionctx.Context, node ast.Node, preprocessOpt ...PreprocessOpt) error { v := preprocessor{ctx: ctx, tableAliasInJoin: make([]map[string]interface{}, 0), withName: make(map[string]interface{})} diff --git a/planner/core/testdata/integration_serial_suite_out.json b/planner/core/testdata/integration_serial_suite_out.json index fa07e7323f022..8e88ca5157d3f 100644 --- a/planner/core/testdata/integration_serial_suite_out.json +++ b/planner/core/testdata/integration_serial_suite_out.json @@ -1463,7 +1463,7 @@ "StreamAgg 1.00 root funcs:avg(Column#7, Column#8)->Column#4", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 batchCop[tiflash] funcs:count(Column#9)->Column#7, funcs:sum(Column#10)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] test.t.a, cast(test.t.a, decimal(37,4) BINARY)->Column#10", + " └─Projection 10000.00 batchCop[tiflash] test.t.a, cast(test.t.a, decimal(14,4) BINARY)->Column#10", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null @@ -1474,7 +1474,7 @@ "StreamAgg 1.00 root funcs:avg(Column#7, Column#8)->Column#4", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 batchCop[tiflash] funcs:count(Column#9)->Column#7, funcs:sum(Column#10)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] test.t.a, cast(test.t.a, decimal(37,4) BINARY)->Column#10", + " └─Projection 10000.00 batchCop[tiflash] test.t.a, cast(test.t.a, decimal(14,4) BINARY)->Column#10", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null @@ -1485,7 +1485,7 @@ "StreamAgg 1.00 root funcs:sum(Column#6)->Column#4", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 batchCop[tiflash] funcs:sum(Column#7)->Column#6", - " └─Projection 10000.00 batchCop[tiflash] cast(test.t.a, decimal(32,0) BINARY)->Column#7", + " └─Projection 10000.00 batchCop[tiflash] cast(test.t.a, decimal(10,0) BINARY)->Column#7", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null @@ -1496,7 +1496,7 @@ "StreamAgg 1.00 root funcs:sum(Column#6)->Column#4", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 batchCop[tiflash] funcs:sum(Column#7)->Column#6", - " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.a, 1), decimal(41,0) BINARY)->Column#7", + " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.a, 1), decimal(20,0) BINARY)->Column#7", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null @@ -1507,7 +1507,7 @@ "StreamAgg 1.00 root funcs:sum(Column#6)->Column#4", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 batchCop[tiflash] funcs:sum(Column#7)->Column#6", - " └─Projection 10000.00 batchCop[tiflash] cast(isnull(test.t.a), decimal(22,0) BINARY)->Column#7", + " └─Projection 10000.00 batchCop[tiflash] cast(isnull(test.t.a), decimal(20,0) BINARY)->Column#7", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null @@ -1837,7 +1837,7 @@ "HashAgg 1.00 root funcs:sum(Column#8)->Column#6", "└─TableReader 1.00 root data:HashAgg", " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#10)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#10", + " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(20,0) BINARY)->Column#10", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, @@ -1866,7 +1866,7 @@ "StreamAgg 1.00 root funcs:sum(Column#8)->Column#6", "└─TableReader 1.00 root data:StreamAgg", " └─StreamAgg 1.00 batchCop[tiflash] funcs:sum(Column#10)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#10", + " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(20,0) BINARY)->Column#10", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, @@ -1992,7 +1992,7 @@ "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#11)->Column#9", - " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#11", + " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(20,0) BINARY)->Column#11", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, @@ -2024,7 +2024,7 @@ "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#11)->Column#10", - " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#11", + " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(20,0) BINARY)->Column#11", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, @@ -2442,7 +2442,7 @@ "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 batchCop[tiflash] funcs:sum(Column#9)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(41,0) BINARY)->Column#9", + " └─Projection 10000.00 batchCop[tiflash] cast(plus(test.t.id, 1), decimal(20,0) BINARY)->Column#9", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ] }, @@ -2595,7 +2595,7 @@ "└─ExchangeSender 7992.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 7992.00 batchCop[tiflash] Column#7", " └─HashAgg 7992.00 batchCop[tiflash] group by:Column#11, funcs:sum(Column#10)->Column#7", - " └─Projection 12487.50 batchCop[tiflash] cast(test.t.id, decimal(32,0) BINARY)->Column#10, test.t.id", + " └─Projection 12487.50 batchCop[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#10, test.t.id", " └─HashJoin 12487.50 batchCop[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]", " ├─ExchangeReceiver(Build) 9990.00 batchCop[tiflash] ", " │ └─ExchangeSender 9990.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.t.id, collate: N/A]", @@ -2622,7 +2622,7 @@ " │ └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo", " └─Projection(Probe) 7992.00 batchCop[tiflash] Column#11, test.t.id", " └─HashAgg 7992.00 batchCop[tiflash] group by:Column#39, funcs:sum(Column#37)->Column#11, funcs:firstrow(Column#38)->test.t.id", - " └─Projection 9990.00 batchCop[tiflash] cast(test.t.id, decimal(32,0) BINARY)->Column#37, test.t.id, test.t.id", + " └─Projection 9990.00 batchCop[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#37, test.t.id, test.t.id", " └─HashJoin 9990.00 batchCop[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]", " ├─Projection(Build) 7992.00 batchCop[tiflash] test.t.id, Column#13", " │ └─HashAgg 7992.00 batchCop[tiflash] group by:test.t.id, funcs:firstrow(test.t.id)->test.t.id, funcs:sum(Column#17)->Column#13", @@ -2704,7 +2704,7 @@ "└─ExchangeSender 6400.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 6400.00 batchCop[tiflash] Column#4", " └─HashAgg 6400.00 batchCop[tiflash] group by:Column#22, funcs:sum(Column#21)->Column#4", - " └─Projection 6400.00 batchCop[tiflash] cast(test.t.id, decimal(32,0) BINARY)->Column#21, test.t.value", + " └─Projection 6400.00 batchCop[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#21, test.t.value", " └─Projection 6400.00 batchCop[tiflash] test.t.id, test.t.value", " └─HashAgg 6400.00 batchCop[tiflash] group by:test.t.id, test.t.value, funcs:firstrow(test.t.id)->test.t.id, funcs:firstrow(test.t.value)->test.t.value", " └─ExchangeReceiver 6400.00 batchCop[tiflash] ", @@ -2868,7 +2868,7 @@ " └─ExchangeReceiver 7992.00 batchCop[tiflash] ", " └─ExchangeSender 7992.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.t.id, collate: N/A]", " └─HashAgg 7992.00 batchCop[tiflash] group by:Column#11, funcs:sum(Column#10)->Column#8", - " └─Projection 12487.50 batchCop[tiflash] cast(test.t.id, decimal(32,0) BINARY)->Column#10, test.t.id", + " └─Projection 12487.50 batchCop[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#10, test.t.id", " └─HashJoin 12487.50 batchCop[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]", " ├─ExchangeReceiver(Build) 9990.00 batchCop[tiflash] ", " │ └─ExchangeSender 9990.00 batchCop[tiflash] ExchangeType: Broadcast", @@ -2922,7 +2922,7 @@ " └─ExchangeReceiver 7992.00 batchCop[tiflash] ", " └─ExchangeSender 7992.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.t.id, collate: N/A]", " └─HashAgg 7992.00 batchCop[tiflash] group by:Column#33, funcs:sum(Column#32)->Column#17", - " └─Projection 9990.00 batchCop[tiflash] cast(test.t.id, decimal(32,0) BINARY)->Column#32, test.t.id", + " └─Projection 9990.00 batchCop[tiflash] cast(test.t.id, decimal(10,0) BINARY)->Column#32, test.t.id", " └─HashJoin 9990.00 batchCop[tiflash] inner join, equal:[eq(test.t.id, test.t.id)]", " ├─ExchangeReceiver(Build) 7992.00 batchCop[tiflash] ", " │ └─ExchangeSender 7992.00 batchCop[tiflash] ExchangeType: Broadcast", @@ -3157,7 +3157,7 @@ " │ └─TableReader 1.00 root data:ExchangeSender", " │ └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " │ └─HashAgg 1.00 batchCop[tiflash] funcs:min(Column#42)->Column#36, funcs:sum(Column#43)->Column#37, funcs:count(1)->Column#38", - " │ └─Projection 10000.00 batchCop[tiflash] test.ts.col_varchar_64, cast(isnull(test.ts.col_varchar_64), decimal(22,0) BINARY)->Column#43", + " │ └─Projection 10000.00 batchCop[tiflash] test.ts.col_varchar_64, cast(isnull(test.ts.col_varchar_64), decimal(20,0) BINARY)->Column#43", " │ └─TableFullScan 10000.00 batchCop[tiflash] table:SUBQUERY4_t1 keep order:false, stats:pseudo", " └─TableReader(Probe) 12487.50 root data:ExchangeSender", " └─ExchangeSender 12487.50 cop[tiflash] ExchangeType: PassThrough", @@ -3379,7 +3379,7 @@ "└─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 batchCop[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#11, 0), 1, Column#11), decimal(20,0) BINARY))->Column#8", " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#20, funcs:group_concat(Column#13, Column#14, Column#15 order by Column#16 separator \",\")->Column#5, funcs:count(1)->Column#6, funcs:min(Column#17)->Column#7, funcs:count(Column#18)->Column#11, funcs:sum(Column#19)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#15, test.ts.col_0, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#19, test.ts.col_2", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#15, test.ts.col_0, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#19, test.ts.col_2", " └─ExchangeReceiver 10000.00 batchCop[tiflash] ", " └─ExchangeSender 10000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: N/A]", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" @@ -3399,7 +3399,7 @@ " └─ExchangeReceiver 8000.00 batchCop[tiflash] ", " └─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: N/A]", " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#32, Column#33, Column#34, Column#35, funcs:count(1)->Column#25, funcs:max(Column#29)->Column#26, funcs:count(Column#30)->Column#27, funcs:sum(Column#31)->Column#28", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#31, test.ts.col_2, test.ts.col_0, test.ts.col_1, test.ts.id", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#31, test.ts.col_2, test.ts.col_0, test.ts.col_1, test.ts.id", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -3413,7 +3413,7 @@ "└─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 1.00 batchCop[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#10, 0), 1, Column#10), decimal(20,0) BINARY))->Column#8", " └─HashAgg 1.00 batchCop[tiflash] funcs:group_concat(Column#11, Column#12, Column#13 order by Column#14 separator \",\")->Column#5, funcs:count(Column#15)->Column#6, funcs:min(Column#16)->Column#7, funcs:count(Column#17)->Column#10, funcs:sum(Column#18)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#13, test.ts.col_0, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#18", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#13, test.ts.col_0, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#18", " └─ExchangeReceiver 10000.00 batchCop[tiflash] ", " └─ExchangeSender 10000.00 batchCop[tiflash] ExchangeType: PassThrough", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" @@ -3433,7 +3433,7 @@ " └─ExchangeReceiver 1.00 batchCop[tiflash] ", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 batchCop[tiflash] group by:Column#27, Column#28, Column#29, funcs:count(Column#23)->Column#19, funcs:max(Column#24)->Column#20, funcs:count(Column#25)->Column#21, funcs:sum(Column#26)->Column#22", - " └─Projection 10000.00 batchCop[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#26, test.ts.col_0, test.ts.col_1, test.ts.id", + " └─Projection 10000.00 batchCop[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#26, test.ts.col_0, test.ts.col_1, test.ts.id", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -3450,7 +3450,7 @@ " └─ExchangeReceiver 8000.00 batchCop[tiflash] ", " └─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: N/A]", " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#40, funcs:group_concat(Column#33, Column#34, Column#35 separator \",\")->Column#28, funcs:count(Column#36)->Column#29, funcs:min(Column#37)->Column#30, funcs:count(Column#38)->Column#31, funcs:sum(Column#39)->Column#32", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#35, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#39, test.ts.col_2", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#35, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#39, test.ts.col_2", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -3468,7 +3468,7 @@ " └─ExchangeReceiver 8000.00 batchCop[tiflash] ", " └─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: N/A]", " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#33, Column#34, Column#35, Column#36, funcs:count(Column#29)->Column#25, funcs:max(Column#30)->Column#26, funcs:count(Column#31)->Column#27, funcs:sum(Column#32)->Column#28", - " └─Projection 10000.00 batchCop[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#32, test.ts.col_2, test.ts.col_0, test.ts.col_1, test.ts.id", + " └─Projection 10000.00 batchCop[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#32, test.ts.col_2, test.ts.col_0, test.ts.col_1, test.ts.id", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -3482,7 +3482,7 @@ "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 batchCop[tiflash] funcs:group_concat(Column#24, Column#25, Column#26 separator \",\")->Column#14, funcs:count(Column#27)->Column#15, funcs:min(Column#28)->Column#16, funcs:count(Column#29)->Column#17, funcs:sum(Column#30)->Column#18", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#26, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#30", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#26, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#30", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -3500,7 +3500,7 @@ " └─ExchangeReceiver 1.00 batchCop[tiflash] ", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 batchCop[tiflash] group by:Column#27, Column#28, Column#29, funcs:count(Column#23)->Column#19, funcs:max(Column#24)->Column#20, funcs:count(Column#25)->Column#21, funcs:sum(Column#26)->Column#22", - " └─Projection 10000.00 batchCop[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#26, test.ts.col_0, test.ts.col_1, test.ts.id", + " └─Projection 10000.00 batchCop[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#26, test.ts.col_0, test.ts.col_1, test.ts.id", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -3514,7 +3514,7 @@ "└─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 batchCop[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#17, 0), 1, Column#17), decimal(20,0) BINARY))->Column#8", " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#29, funcs:group_concat(Column#21, Column#22, Column#23 separator \",\")->Column#5, funcs:count(Column#24)->Column#6, funcs:group_concat(Column#25 order by Column#26 separator \",\")->Column#7, funcs:count(Column#27)->Column#17, funcs:sum(Column#28)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#23, test.ts.id, test.ts.col_0, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#28, test.ts.col_2", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#23, test.ts.id, test.ts.col_0, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#28, test.ts.col_2", " └─ExchangeReceiver 10000.00 batchCop[tiflash] ", " └─ExchangeSender 10000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: N/A]", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" @@ -3530,7 +3530,7 @@ "└─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 batchCop[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#14, 0), 1, Column#14), decimal(20,0) BINARY))->Column#8", " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#25, funcs:group_concat(distinct Column#17 separator \",\")->Column#5, funcs:count(Column#18)->Column#6, funcs:group_concat(Column#19, Column#20 order by Column#21, Column#22 separator \",\")->Column#7, funcs:count(Column#23)->Column#14, funcs:sum(Column#24)->Column#8", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#20, test.ts.col_1, test.ts.id, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#24, test.ts.col_2", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#20, test.ts.col_1, test.ts.id, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#24, test.ts.col_2", " └─ExchangeReceiver 10000.00 batchCop[tiflash] ", " └─ExchangeSender 10000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: N/A]", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" @@ -3546,7 +3546,7 @@ "└─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 1.00 batchCop[tiflash] Column#5, Column#6, Column#7, Column#8, div(Column#9, cast(case(eq(Column#15, 0), 1, Column#15), decimal(20,0) BINARY))->Column#9", " └─HashAgg 1.00 batchCop[tiflash] funcs:group_concat(Column#18, Column#19 separator \",\")->Column#5, funcs:count(Column#20)->Column#6, funcs:group_concat(Column#21, Column#22 order by Column#23, Column#24 separator \",\")->Column#7, funcs:min(Column#25)->Column#8, funcs:count(Column#26)->Column#15, funcs:sum(Column#27)->Column#9", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, cast(test.ts.id, var_string(20))->Column#19, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#22, test.ts.col_1, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#27", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, cast(test.ts.id, var_string(20))->Column#19, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#22, test.ts.col_1, test.ts.id, test.ts.col_0, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#27", " └─ExchangeReceiver 10000.00 batchCop[tiflash] ", " └─ExchangeSender 10000.00 batchCop[tiflash] ExchangeType: PassThrough", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" @@ -3562,7 +3562,7 @@ "└─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─Projection 1.00 batchCop[tiflash] Column#5, Column#6, Column#7, Column#8, div(Column#9, cast(case(eq(Column#13, 0), 1, Column#13), decimal(20,0) BINARY))->Column#9", " └─HashAgg 1.00 batchCop[tiflash] funcs:group_concat(distinct Column#15, Column#16, Column#17 separator \",\")->Column#5, funcs:count(Column#18)->Column#6, funcs:group_concat(Column#19, Column#20 order by Column#21, Column#22 separator \",\")->Column#7, funcs:max(Column#23)->Column#8, funcs:count(Column#24)->Column#13, funcs:sum(Column#25)->Column#9", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#17, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#20, test.ts.col_1, test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#25", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#17, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#20, test.ts.col_1, test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#25", " └─ExchangeReceiver 10000.00 batchCop[tiflash] ", " └─ExchangeSender 10000.00 batchCop[tiflash] ExchangeType: PassThrough", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" @@ -3582,7 +3582,7 @@ " └─ExchangeReceiver 1.00 batchCop[tiflash] ", " └─ExchangeSender 1.00 batchCop[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 batchCop[tiflash] group by:Column#29, Column#30, Column#31, Column#32, funcs:group_concat(Column#24, Column#25 separator \",\")->Column#20, funcs:max(Column#26)->Column#21, funcs:count(Column#27)->Column#22, funcs:sum(Column#28)->Column#23", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_1, cast(test.ts.id, var_string(20))->Column#25, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#28, test.ts.col_0, test.ts.col_1, test.ts.id, test.ts.col_2", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_1, cast(test.ts.id, var_string(20))->Column#25, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#28, test.ts.col_0, test.ts.col_1, test.ts.id, test.ts.col_2", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -3600,7 +3600,7 @@ " └─ExchangeReceiver 8000.00 batchCop[tiflash] ", " └─ExchangeSender 8000.00 batchCop[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_0, collate: N/A]", " └─HashAgg 8000.00 batchCop[tiflash] group by:Column#35, Column#36, Column#37, Column#38, funcs:group_concat(Column#30, Column#31 separator \",\")->Column#26, funcs:max(Column#32)->Column#27, funcs:count(Column#33)->Column#28, funcs:sum(Column#34)->Column#29", - " └─Projection 10000.00 batchCop[tiflash] test.ts.col_1, cast(test.ts.id, var_string(20))->Column#31, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(37,4) BINARY)->Column#34, test.ts.col_0, test.ts.col_1, test.ts.id, test.ts.col_2", + " └─Projection 10000.00 batchCop[tiflash] test.ts.col_1, cast(test.ts.id, var_string(20))->Column#31, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#34, test.ts.col_0, test.ts.col_1, test.ts.id, test.ts.col_2", " └─TableFullScan 10000.00 batchCop[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ diff --git a/planner/core/testdata/ordered_result_mode_suite_out.json b/planner/core/testdata/ordered_result_mode_suite_out.json index 80d8b06a86fd6..8016c33bed6f4 100644 --- a/planner/core/testdata/ordered_result_mode_suite_out.json +++ b/planner/core/testdata/ordered_result_mode_suite_out.json @@ -401,7 +401,7 @@ "Plan": [ "Projection_8 10000.00 root Column#6", "└─Sort_9 10000.00 root test.t1.b, test.t1.a, Column#6", - " └─Window_11 10000.00 root sum(cast(test.t1.b, decimal(32,0) BINARY))->Column#6 over(partition by test.t1.a)", + " └─Window_11 10000.00 root sum(cast(test.t1.b, decimal(10,0) BINARY))->Column#6 over(partition by test.t1.a)", " └─TableReader_13 10000.00 root data:TableFullScan_12", " └─TableFullScan_12 10000.00 cop[tikv] table:t1 keep order:true, stats:pseudo" ] diff --git a/planner/core/testdata/plan_suite_out.json b/planner/core/testdata/plan_suite_out.json index 75db6cb736e99..f70d1eb7e5550 100644 --- a/planner/core/testdata/plan_suite_out.json +++ b/planner/core/testdata/plan_suite_out.json @@ -1705,7 +1705,7 @@ "SQL": "select /*+ HASH_AGG(), AGG_TO_COP() */ sum(distinct b) from pt;", "Plan": [ "HashAgg 1.00 root funcs:sum(distinct Column#9)->Column#4", - "└─Projection 16000.00 root cast(test.pt.b, decimal(32,0) BINARY)->Column#9", + "└─Projection 16000.00 root cast(test.pt.b, decimal(10,0) BINARY)->Column#9", " └─PartitionUnion 16000.00 root ", " ├─HashAgg 8000.00 root group by:test.pt.b, funcs:firstrow(test.pt.b)->test.pt.b, funcs:firstrow(test.pt.b)->test.pt.b", " │ └─TableReader 8000.00 root data:HashAgg", @@ -1788,7 +1788,7 @@ "Plan": [ "Projection 8000.00 root Column#5, test.t.c, Column#5, Column#6, Column#7, Column#8, Column#9", "└─HashAgg 8000.00 root group by:Column#17, funcs:avg(Column#10)->Column#5, funcs:count(distinct Column#11, Column#12)->Column#6, funcs:count(distinct Column#13)->Column#7, funcs:count(distinct Column#14)->Column#8, funcs:sum(Column#15)->Column#9, funcs:firstrow(Column#16)->test.t.c", - " └─Projection 10000.00 root cast(test.t.b, decimal(15,4) BINARY)->Column#10, test.t.a, test.t.b, test.t.a, test.t.c, cast(test.t.b, decimal(32,0) BINARY)->Column#15, test.t.c, test.t.c", + " └─Projection 10000.00 root cast(test.t.b, decimal(15,4) BINARY)->Column#10, test.t.a, test.t.b, test.t.a, test.t.c, cast(test.t.b, decimal(10,0) BINARY)->Column#15, test.t.c, test.t.c", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], @@ -1850,7 +1850,7 @@ "SQL": "select /*+ HASH_AGG(), AGG_TO_COP() */ sum(distinct b) from pt;", "Plan": [ "HashAgg 1.00 root funcs:sum(distinct Column#9)->Column#4", - "└─Projection 16000.00 root cast(test.pt.b, decimal(32,0) BINARY)->Column#9", + "└─Projection 16000.00 root cast(test.pt.b, decimal(10,0) BINARY)->Column#9", " └─PartitionUnion 16000.00 root ", " ├─HashAgg 8000.00 root group by:test.pt.b, funcs:firstrow(test.pt.b)->test.pt.b, funcs:firstrow(test.pt.b)->test.pt.b", " │ └─TableReader 8000.00 root data:HashAgg", @@ -1892,7 +1892,7 @@ "SQL": "select /*+ HASH_AGG(), AGG_TO_COP() */ sum(distinct b) from pt;", "Plan": [ "HashAgg 1.00 root funcs:sum(distinct Column#9)->Column#4", - "└─Projection 16000.00 root cast(test.pt.b, decimal(32,0) BINARY)->Column#9", + "└─Projection 16000.00 root cast(test.pt.b, decimal(10,0) BINARY)->Column#9", " └─PartitionUnion 16000.00 root ", " ├─HashAgg 8000.00 root group by:test.pt.b, funcs:firstrow(test.pt.b)->test.pt.b, funcs:firstrow(test.pt.b)->test.pt.b", " │ └─TableReader 8000.00 root data:HashAgg", diff --git a/planner/core/testdata/plan_suite_unexported_out.json b/planner/core/testdata/plan_suite_unexported_out.json index 6401df6aa9264..391797fa59644 100644 --- a/planner/core/testdata/plan_suite_unexported_out.json +++ b/planner/core/testdata/plan_suite_unexported_out.json @@ -93,7 +93,7 @@ "Join{DataScan(t1)->DataScan(t2)}(test.t.a,test.t.a)->Projection", "Dual->Projection", "DataScan(t)->Projection->Projection->Window(min(test.t.a)->Column#14)->Sel([lt(test.t.a, 10) eq(test.t.b, Column#14)])->Projection->Projection", - "DataScan(t)->Projection->Projection->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14)->Sel([gt(Column#14, cast(test.t.b, decimal(20,0) BINARY))])->Projection->Projection" + "DataScan(t)->Projection->Projection->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14)->Sel([gt(Column#14, cast(test.t.b, decimal(20,0) BINARY))])->Projection->Projection" ] }, { @@ -189,12 +189,12 @@ "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(order by test.t.a, test.t.b desc range between unbounded preceding and current row))->Projection", "TableReader(Table(t))->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(partition by test.t.a))->Projection", "[planner:1054]Unknown column 'z' in 'field list'", - "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(65,0) BINARY))->Column#14 over())->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(10,0) BINARY))->Column#14 over())->Sort->Projection", "IndexReader(Index(t.f)[[NULL,+inf]]->StreamAgg)->StreamAgg->Window(sum(Column#13)->Column#15 over())->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over())->Sort->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over())->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", "TableReader(Table(t)->StreamAgg)->StreamAgg->Window(sum(Column#13)->Column#15 over())->Sort->Projection", - "Apply{IndexReader(Index(t.f)[[NULL,+inf]])->IndexReader(Index(t.f)[[NULL,+inf]]->Sel([gt(test.t.a, test.t.a)]))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#38 over())->MaxOneRow}->Sel([Column#38])->Projection", + "Apply{IndexReader(Index(t.f)[[NULL,+inf]])->IndexReader(Index(t.f)[[NULL,+inf]]->Sel([gt(test.t.a, test.t.a)]))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#38 over())->MaxOneRow}->Sel([Column#38])->Projection", "[planner:3594]You cannot use the alias 'w' of an expression containing a window function in this context.'", "[planner:1247]Reference 'sum_a' not supported (reference to window function)", "[planner:3579]Window name 'w2' is not defined.", @@ -203,11 +203,11 @@ "[planner:3581]A window which depends on another cannot define partitioning.", "[planner:3581]A window which depends on another cannot define partitioning.", "[planner:3582]Window 'w' has a frame definition, so cannot be referenced by another window.", - "IndexReader(Index(t.f)[[NULL,+inf]])->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(rows between 1 preceding and 1 following))->Projection", + "IndexReader(Index(t.f)[[NULL,+inf]])->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(rows between 1 preceding and 1 following))->Projection", "[planner:3583]Window '' cannot inherit 'w' since both contain an ORDER BY clause.", "[planner:3591]Window 'w1' is defined twice.", "TableReader(Table(t))->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(partition by test.t.a))->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", "[planner:1235]This version of TiDB doesn't yet support 'GROUPS'", "[planner:3584]Window '': frame start cannot be UNBOUNDED FOLLOWING.", "[planner:3585]Window '': frame end cannot be UNBOUNDED PRECEDING.", @@ -219,7 +219,7 @@ "[planner:3590]Window '' has a non-constant frame bound.", "[planner:3586]Window '': frame start or end is negative, NULL or of non-integral type", "[planner:3588]Window '' with RANGE frame has ORDER BY expression of datetime type. Only INTERVAL bound value allowed.", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(order by test.t.a range between 1.0 preceding and 1 following))->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(order by test.t.a range between 1.0 preceding and 1 following))->Projection", "IndexReader(Index(t.f)[[NULL,+inf]])->Window(row_number()->Column#14 over())->Projection", "TableReader(Table(t))->HashAgg->Window(max(Column#13)->Column#15 over(rows between 1 preceding and 1 following))->Projection", "[planner:1210]Incorrect arguments to nth_value", @@ -229,11 +229,11 @@ "IndexReader(Index(t.f)[[NULL,+inf]])->Window(ntile()->Column#14 over())->Projection", "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(partition by test.t.b))->Projection", "TableReader(Table(t))->Window(nth_value(test.t.i_date, 1)->Column#14 over())->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(65,0) BINARY))->Column#15, sum(cast(test.t.c, decimal(65,0) BINARY))->Column#16 over(order by test.t.a range between unbounded preceding and current row))->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(10,0) BINARY))->Column#15, sum(cast(test.t.c, decimal(10,0) BINARY))->Column#16 over(order by test.t.a range between unbounded preceding and current row))->Projection", "[planner:3593]You cannot use the window function 'sum' in this context.'", "[planner:3593]You cannot use the window function 'sum' in this context.'", "[planner:3593]You cannot use the window function 'row_number' in this context.'", - "TableReader(Table(t))->Sort->Window(sum(cast(test.t.c, decimal(65,0) BINARY))->Column#17 over(partition by test.t.a order by test.t.c range between unbounded preceding and current row))->Sort->Window(sum(cast(test.t.b, decimal(65,0) BINARY))->Column#18 over(order by test.t.a, test.t.b, test.t.c range between unbounded preceding and current row))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#19 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row))->Window(sum(cast(test.t.d, decimal(65,0) BINARY))->Column#20 over())->Projection", + "TableReader(Table(t))->Sort->Window(sum(cast(test.t.c, decimal(10,0) BINARY))->Column#17 over(partition by test.t.a order by test.t.c range between unbounded preceding and current row))->Sort->Window(sum(cast(test.t.b, decimal(10,0) BINARY))->Column#18 over(order by test.t.a, test.t.b, test.t.c range between unbounded preceding and current row))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#19 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row))->Window(sum(cast(test.t.d, decimal(10,0) BINARY))->Column#20 over())->Projection", "[planner:3587]Window 'w1' with RANGE N PRECEDING/FOLLOWING frame requires exactly one ORDER BY expression, of numeric or temporal type", "TableReader(Table(t))->Sort->Window(dense_rank()->Column#14 over(partition by test.t.b order by test.t.a desc, test.t.b desc))->Projection", "[planner:3587]Window 'w1' with RANGE N PRECEDING/FOLLOWING frame requires exactly one ORDER BY expression, of numeric or temporal type", @@ -262,12 +262,12 @@ "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(order by test.t.a, test.t.b desc range between unbounded preceding and current row))->Projection", "TableReader(Table(t))->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(partition by test.t.a))->Projection", "[planner:1054]Unknown column 'z' in 'field list'", - "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(65,0) BINARY))->Column#14 over())->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(10,0) BINARY))->Column#14 over())->Sort->Projection", "IndexReader(Index(t.f)[[NULL,+inf]]->StreamAgg)->StreamAgg->Window(sum(Column#13)->Column#15 over())->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over())->Sort->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over())->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", "TableReader(Table(t)->StreamAgg)->StreamAgg->Window(sum(Column#13)->Column#15 over())->Sort->Projection", - "Apply{IndexReader(Index(t.f)[[NULL,+inf]])->IndexReader(Index(t.f)[[NULL,+inf]]->Sel([gt(test.t.a, test.t.a)]))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#38 over())->MaxOneRow}->Sel([Column#38])->Projection", + "Apply{IndexReader(Index(t.f)[[NULL,+inf]])->IndexReader(Index(t.f)[[NULL,+inf]]->Sel([gt(test.t.a, test.t.a)]))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#38 over())->MaxOneRow}->Sel([Column#38])->Projection", "[planner:3594]You cannot use the alias 'w' of an expression containing a window function in this context.'", "[planner:1247]Reference 'sum_a' not supported (reference to window function)", "[planner:3579]Window name 'w2' is not defined.", @@ -276,11 +276,11 @@ "[planner:3581]A window which depends on another cannot define partitioning.", "[planner:3581]A window which depends on another cannot define partitioning.", "[planner:3582]Window 'w' has a frame definition, so cannot be referenced by another window.", - "IndexReader(Index(t.f)[[NULL,+inf]])->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(rows between 1 preceding and 1 following))->Projection", + "IndexReader(Index(t.f)[[NULL,+inf]])->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(rows between 1 preceding and 1 following))->Projection", "[planner:3583]Window '' cannot inherit 'w' since both contain an ORDER BY clause.", "[planner:3591]Window 'w1' is defined twice.", "TableReader(Table(t))->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(partition by test.t.a))->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(partition by test.t.a))->Sort->Projection", "[planner:1235]This version of TiDB doesn't yet support 'GROUPS'", "[planner:3584]Window '': frame start cannot be UNBOUNDED FOLLOWING.", "[planner:3585]Window '': frame end cannot be UNBOUNDED PRECEDING.", @@ -292,7 +292,7 @@ "[planner:3590]Window '' has a non-constant frame bound.", "[planner:3586]Window '': frame start or end is negative, NULL or of non-integral type", "[planner:3588]Window '' with RANGE frame has ORDER BY expression of datetime type. Only INTERVAL bound value allowed.", - "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#14 over(order by test.t.a range between 1.0 preceding and 1 following))->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#14 over(order by test.t.a range between 1.0 preceding and 1 following))->Projection", "IndexReader(Index(t.f)[[NULL,+inf]])->Window(row_number()->Column#14 over())->Projection", "TableReader(Table(t))->HashAgg->Window(max(Column#13)->Column#15 over(rows between 1 preceding and 1 following))->Projection", "[planner:1210]Incorrect arguments to nth_value", @@ -302,11 +302,11 @@ "IndexReader(Index(t.f)[[NULL,+inf]])->Window(ntile()->Column#14 over())->Projection", "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(partition by test.t.b))->Partition(execution info: concurrency:4, data sources:[TableReader_10])->Projection", "TableReader(Table(t))->Window(nth_value(test.t.i_date, 1)->Column#14 over())->Projection", - "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(65,0) BINARY))->Column#15, sum(cast(test.t.c, decimal(65,0) BINARY))->Column#16 over(order by test.t.a range between unbounded preceding and current row))->Projection", + "TableReader(Table(t))->Window(sum(cast(test.t.b, decimal(10,0) BINARY))->Column#15, sum(cast(test.t.c, decimal(10,0) BINARY))->Column#16 over(order by test.t.a range between unbounded preceding and current row))->Projection", "[planner:3593]You cannot use the window function 'sum' in this context.'", "[planner:3593]You cannot use the window function 'sum' in this context.'", "[planner:3593]You cannot use the window function 'row_number' in this context.'", - "TableReader(Table(t))->Sort->Window(sum(cast(test.t.c, decimal(65,0) BINARY))->Column#17 over(partition by test.t.a order by test.t.c range between unbounded preceding and current row))->Sort->Window(sum(cast(test.t.b, decimal(65,0) BINARY))->Column#18 over(order by test.t.a, test.t.b, test.t.c range between unbounded preceding and current row))->Window(sum(cast(test.t.a, decimal(65,0) BINARY))->Column#19 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row))->Window(sum(cast(test.t.d, decimal(65,0) BINARY))->Column#20 over())->Projection", + "TableReader(Table(t))->Sort->Window(sum(cast(test.t.c, decimal(10,0) BINARY))->Column#17 over(partition by test.t.a order by test.t.c range between unbounded preceding and current row))->Sort->Window(sum(cast(test.t.b, decimal(10,0) BINARY))->Column#18 over(order by test.t.a, test.t.b, test.t.c range between unbounded preceding and current row))->Window(sum(cast(test.t.a, decimal(10,0) BINARY))->Column#19 over(partition by test.t.a order by test.t.b range between unbounded preceding and current row))->Window(sum(cast(test.t.d, decimal(10,0) BINARY))->Column#20 over())->Projection", "[planner:3587]Window 'w1' with RANGE N PRECEDING/FOLLOWING frame requires exactly one ORDER BY expression, of numeric or temporal type", "TableReader(Table(t))->Sort->Window(dense_rank()->Column#14 over(partition by test.t.b order by test.t.a desc, test.t.b desc))->Partition(execution info: concurrency:4, data sources:[TableReader_9])->Projection", "[planner:3587]Window 'w1' with RANGE N PRECEDING/FOLLOWING frame requires exactly one ORDER BY expression, of numeric or temporal type", diff --git a/planner/core/testdata/stats_suite_out.json b/planner/core/testdata/stats_suite_out.json index f7e40ddcc0e61..369fbe4fb0adf 100644 --- a/planner/core/testdata/stats_suite_out.json +++ b/planner/core/testdata/stats_suite_out.json @@ -275,7 +275,7 @@ "SQL": "select count(tmp.a_sum) from (select t1.a as a, t1.b as b, sum(a) over() as a_sum from t1) tmp group by tmp.a, tmp.b", "Plan": [ "HashAgg 4.00 root group by:test.t1.a, test.t1.b, funcs:count(Column#5)->Column#6", - "└─Window 4.00 root sum(cast(test.t1.a, decimal(32,0) BINARY))->Column#5 over()", + "└─Window 4.00 root sum(cast(test.t1.a, decimal(10,0) BINARY))->Column#5 over()", " └─TableReader 4.00 root data:TableFullScan", " └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false" ]