From 5df919aefae7aeab0f0969e20367a7284e9eb7e7 Mon Sep 17 00:00:00 2001 From: xufei Date: Wed, 20 Jul 2022 17:23:31 +0800 Subject: [PATCH 1/8] avoid change the type of the input of sum/avg Signed-off-by: xufei --- expression/aggregation/base_func.go | 22 ---------------------- expression/builtin_cast.go | 1 + 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/expression/aggregation/base_func.go b/expression/aggregation/base_func.go index f9f5f916a3232..e7ae700b092f4 100644 --- a/expression/aggregation/base_func.go +++ b/expression/aggregation/base_func.go @@ -423,28 +423,6 @@ func (a *baseFuncDesc) WrapCastForAggArgs(ctx sessionctx.Context) { } tpOld := a.Args[i].GetType().GetType() a.Args[i] = castFunc(ctx, a.Args[i]) - if a.Name != ast.AggFuncAvg && a.Name != ast.AggFuncSum { - continue - } - // After wrapping cast on the argument, flen etc. may not the same - // as the type of the aggregation function. The following part set - // the type of the argument exactly as the type of the aggregation - // function. - // Note: If the `tp` of argument is the same as the `tp` of the - // aggregation function, it will not wrap cast function on it - // internally. The reason of the special handling for `Column` is - // that the `RetType` of `Column` refers to the `infoschema`, so we - // need to set a new variable for it to avoid modifying the - // definition in `infoschema`. - if col, ok := a.Args[i].(*expression.Column); ok { - col.RetType = types.NewFieldType(col.RetType.GetType()) - } - // originTp is used when the `tp` of column is TypeFloat32 while - // the type of the aggregation function is TypeFloat64. - originTp := a.Args[i].GetType().GetType() - *(a.Args[i].GetType()) = *(a.RetTp) - a.Args[i].GetType().SetType(originTp) - // refine each mysql integer type to the needed decimal precision for sum if a.Name == ast.AggFuncSum { adjustDecimalLenForSumInteger(a.Args[i].GetType(), tpOld) diff --git a/expression/builtin_cast.go b/expression/builtin_cast.go index 3100f33f612d4..3754550fe086a 100644 --- a/expression/builtin_cast.go +++ b/expression/builtin_cast.go @@ -1941,6 +1941,7 @@ func WrapWithCastAsDecimal(ctx sessionctx.Context, expr Expression) Expression { tp.SetDecimalUnderLimit(expr.GetType().GetDecimal()) if expr.GetType().EvalType() == types.ETInt { + // todo set the flen returned by minimalDecimalLenForHoldingInteger tp.SetFlen(mysql.MaxIntWidth) } if tp.GetFlen() == types.UnspecifiedLength || tp.GetFlen() > mysql.MaxDecimalWidth { From de4372e55db33fdbe5729fe8ff01f427d17c81ac Mon Sep 17 00:00:00 2001 From: xufei Date: Thu, 21 Jul 2022 13:58:35 +0800 Subject: [PATCH 2/8] fix tests in explain_test Signed-off-by: xufei --- cmd/explaintest/r/agg_predicate_pushdown.result | 10 +++++----- cmd/explaintest/r/explain_easy.result | 12 ++++++------ cmd/explaintest/r/index_merge.result | 2 +- expression/builtin_cast.go | 1 + types/field_type.go | 16 ++++++++++++++-- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/cmd/explaintest/r/agg_predicate_pushdown.result b/cmd/explaintest/r/agg_predicate_pushdown.result index 9caca7aa5bb22..b04d3983eba50 100644 --- a/cmd/explaintest/r/agg_predicate_pushdown.result +++ b/cmd/explaintest/r/agg_predicate_pushdown.result @@ -7,7 +7,7 @@ id estRows task access object operator info Projection 711.11 root test.t.a, test.t.b, Column#5 └─Selection 711.11 root gt(Column#5, 3) └─HashAgg 888.89 root group by:Column#16, Column#17, Column#18, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->test.t.a, funcs:firstrow(Column#15)->test.t.b - └─Projection 1111.11 root cast(test.t.c, decimal(15,4) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c + └─Projection 1111.11 root cast(test.t.c, decimal(20,0) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c └─TableReader 1111.11 root data:Selection └─Selection 1111.11 cop[tikv] gt(test.t.a, 1), gt(test.t.a, 2), gt(test.t.b, 2) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -17,7 +17,7 @@ id estRows task access object operator info Projection 657.65 root test.t.a, test.t.b, Column#5 └─Selection 657.65 root gt(Column#5, 3) └─HashAgg 822.06 root group by:Column#16, Column#17, Column#18, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->test.t.a, funcs:firstrow(Column#15)->test.t.b - └─Projection 1027.57 root cast(test.t.c, decimal(15,4) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c + └─Projection 1027.57 root cast(test.t.c, decimal(20,0) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c └─TableReader 1027.57 root data:Selection └─Selection 1027.57 cop[tikv] gt(test.t.b, 2), or(gt(test.t.a, 1), gt(test.t.b, 2)), or(gt(test.t.a, 2), lt(test.t.b, 1)) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -27,7 +27,7 @@ id estRows task access object operator info Projection 3027.54 root test.t.a, test.t.b, Column#5 └─Selection 3027.54 root or(and(gt(test.t.a, 1), gt(test.t.b, 2)), or(and(gt(test.t.a, 2), lt(test.t.b, 1)), and(gt(test.t.b, 2), gt(Column#5, 3)))) └─HashAgg 3784.43 root group by:Column#16, Column#17, Column#18, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->test.t.a, funcs:firstrow(Column#15)->test.t.b - └─Projection 4730.53 root cast(test.t.c, decimal(15,4) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c + └─Projection 4730.53 root cast(test.t.c, decimal(20,0) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c └─TableReader 4730.53 root data:Selection └─Selection 4730.53 cop[tikv] or(and(gt(test.t.a, 1), gt(test.t.b, 2)), or(and(gt(test.t.a, 2), lt(test.t.b, 1)), gt(test.t.b, 2))) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -37,7 +37,7 @@ id estRows task access object operator info Projection 2126.93 root test.t.a, test.t.b, Column#5 └─Selection 2126.93 root or(gt(test.t.a, 1), gt(Column#5, 1)) └─HashAgg 2658.67 root group by:Column#16, Column#17, Column#18, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->test.t.a, funcs:firstrow(Column#15)->test.t.b - └─Projection 3323.33 root cast(test.t.c, decimal(15,4) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c + └─Projection 3323.33 root cast(test.t.c, decimal(20,0) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c └─TableReader 3323.33 root data:Selection └─Selection 3323.33 cop[tikv] lt(test.t.a, 3) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo @@ -47,7 +47,7 @@ id estRows task access object operator info Projection 6393.60 root test.t.a, test.t.b, Column#5 └─Selection 6393.60 root or(and(gt(test.t.a, 1), gt(Column#5, 1)), lt(test.t.a, 3)) └─HashAgg 7992.00 root group by:Column#16, Column#17, Column#18, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->test.t.a, funcs:firstrow(Column#15)->test.t.b - └─Projection 9990.00 root cast(test.t.c, decimal(15,4) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c + └─Projection 9990.00 root cast(test.t.c, decimal(20,0) BINARY)->Column#13, test.t.a, test.t.b, test.t.a, test.t.b, test.t.c └─TableReader 9990.00 root data:Selection └─Selection 9990.00 cop[tikv] or(gt(test.t.a, 1), lt(test.t.a, 3)) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo diff --git a/cmd/explaintest/r/explain_easy.result b/cmd/explaintest/r/explain_easy.result index f638a0cc4c62b..76ffb42492b5c 100644 --- a/cmd/explaintest/r/explain_easy.result +++ b/cmd/explaintest/r/explain_easy.result @@ -763,7 +763,7 @@ explain format = 'brief' select a, b from (select a, b, avg(b) over (partition b id estRows task access object operator info Projection 2666.67 root test.t.a, test.t.b └─Selection 2666.67 root gt(cast(test.t.a, decimal(20,0) BINARY), Column#5), lt(test.t.b, 10) - └─Window 3333.33 root avg(cast(test.t.b, decimal(15,4) BINARY))->Column#5 over(partition by test.t.a) + └─Window 3333.33 root avg(cast(test.t.b, decimal(20,0) BINARY))->Column#5 over(partition by test.t.a) └─Sort 3333.33 root test.t.a └─TableReader 3333.33 root data:Selection └─Selection 3333.33 cop[tikv] gt(test.t.a, 10) @@ -925,7 +925,7 @@ StreamAgg 1.00 root funcs:sum(Column#14)->Column#13 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 +└─Projection 12487.50 root cast(test.t.a, decimal(20,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)) @@ -936,7 +936,7 @@ StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 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 +└─Projection 12487.50 root cast(test.t.b, decimal(20,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)) @@ -947,7 +947,7 @@ StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 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 +└─Projection 12487.50 root cast(test.t.c, decimal(20,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)) @@ -958,7 +958,7 @@ StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 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 +└─Projection 12487.50 root cast(test.t.d, decimal(20,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)) @@ -969,7 +969,7 @@ StreamAgg 1.00 root funcs:avg(Column#14)->Column#13 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 +└─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)) diff --git a/cmd/explaintest/r/index_merge.result b/cmd/explaintest/r/index_merge.result index 8a9ad2afcd4c3..68c87ca9a370a 100644 --- a/cmd/explaintest/r/index_merge.result +++ b/cmd/explaintest/r/index_merge.result @@ -536,7 +536,7 @@ Sort_16 1841.86 root test.t1.c1 │ └─TableRowIDScan_24 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo └─TopN_29(Probe) 1.00 root test.t2.c1, offset:2, count:1 └─HashAgg_36 2660.44 root group by:Column#21, funcs:avg(Column#19)->Column#9, funcs:firstrow(Column#20)->test.t2.c1 - └─Projection_48 3325.55 root cast(test.t2.c1, decimal(15,4) BINARY)->Column#19, test.t2.c1, test.t2.c1 + └─Projection_48 3325.55 root cast(test.t2.c1, decimal(20,0) BINARY)->Column#19, test.t2.c1, test.t2.c1 └─IndexMerge_41 3325.55 root ├─Selection_38(Build) 3.32 cop[tikv] eq(test.t1.c1, test.t2.c1) │ └─IndexRangeScan_37 3323.33 cop[tikv] table:t2, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo diff --git a/expression/builtin_cast.go b/expression/builtin_cast.go index 3754550fe086a..ce34f71f6d3a4 100644 --- a/expression/builtin_cast.go +++ b/expression/builtin_cast.go @@ -1943,6 +1943,7 @@ func WrapWithCastAsDecimal(ctx sessionctx.Context, expr Expression) Expression { if expr.GetType().EvalType() == types.ETInt { // todo set the flen returned by minimalDecimalLenForHoldingInteger tp.SetFlen(mysql.MaxIntWidth) + tp.SetDecimal(0) } if tp.GetFlen() == types.UnspecifiedLength || tp.GetFlen() > mysql.MaxDecimalWidth { tp.SetFlen(mysql.MaxDecimalWidth) diff --git a/types/field_type.go b/types/field_type.go index 94e9d04580d33..12235ebd5b2a1 100644 --- a/types/field_type.go +++ b/types/field_type.go @@ -41,12 +41,13 @@ type FieldType = ast.FieldType // with a type and other information about field type. func NewFieldType(tp byte) *FieldType { charset1, collate1 := DefaultCharsetForType(tp) + flen, decimal := MaxFlenAndDecimalForType(tp) return NewFieldTypeBuilder(). SetType(tp). SetCharset(charset1). SetCollate(collate1). - SetFlen(UnspecifiedLength). - SetDecimal(UnspecifiedLength). + SetFlen(flen). + SetDecimal(decimal). BuildP() } @@ -332,6 +333,17 @@ func DefaultTypeForValue(value interface{}, tp *FieldType, char string, collate } } +// MaxFlenAndDecimalForType returns the default flen/decimal for mysql type. +func MaxFlenAndDecimalForType(tp byte) (int, int) { + switch tp { + case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong, mysql.TypeYear: + return mysql.GetDefaultFieldLengthAndDecimal(tp) + default: + // todo support non-integer type + return UnspecifiedLength, UnspecifiedLength + } +} + // DefaultCharsetForType returns the default charset/collation for mysql type. func DefaultCharsetForType(tp byte) (defaultCharset string, defaultCollation string) { switch tp { From 0cdb51f5b6ed8560c970257ca14ee53c0330bc26 Mon Sep 17 00:00:00 2001 From: xufei Date: Thu, 21 Jul 2022 17:11:37 +0800 Subject: [PATCH 3/8] fix ci Signed-off-by: xufei --- .../testdata/integration_suite_out.json | 10 ++++---- .../transformation_rules_suite_out.json | 6 ++--- planner/core/testdata/plan_suite_out.json | 8 +++---- .../testdata/plan_suite_unexported_out.json | 24 +++++++++---------- .../testdata/window_push_down_suite_out.json | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/planner/cascades/testdata/integration_suite_out.json b/planner/cascades/testdata/integration_suite_out.json index 21b601bfc9198..7c56001885264 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(10,0) BINARY)->Column#12, test.t.b, test.t.b", + " └─Projection_20 10000.00 root cast(test.t.a, decimal(20,0) 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" ], @@ -450,7 +450,7 @@ "SQL": "select count(b), sum(b), avg(b), b, max(b), min(b), bit_and(b), bit_or(b), bit_xor(b) from t group by a having sum(b) >= 0 and count(b) >= 0 order by b", "Plan": [ "Projection_13 8000.00 root Column#3, Column#4, Column#5, test.t.b, Column#6, Column#7, Column#8, Column#9, Column#10", - "└─Projection_15 8000.00 root if(isnull(test.t.b), 0, 1)->Column#3, cast(test.t.b, decimal(32,0) BINARY)->Column#4, cast(test.t.b, decimal(15,4) BINARY)->Column#5, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#8, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#9, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#10, cast(test.t.b, decimal(32,0) BINARY)->Column#4, if(isnull(test.t.b), 0, 1)->Column#3", + "└─Projection_15 8000.00 root if(isnull(test.t.b), 0, 1)->Column#3, cast(test.t.b, decimal(32,0) BINARY)->Column#4, cast(test.t.b, decimal(20,0) BINARY)->Column#5, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#8, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#9, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#10, cast(test.t.b, decimal(32,0) BINARY)->Column#4, if(isnull(test.t.b), 0, 1)->Column#3", " └─Sort_22 8000.00 root test.t.b", " └─TableReader_19 8000.00 root data:Selection_20", " └─Selection_20 8000.00 cop[tikv] ge(cast(test.t.b, decimal(32,0) BINARY), 0), ge(if(isnull(test.t.b), 0, 1), 0)", @@ -501,7 +501,7 @@ "SQL": "select /*+ HASH_AGG() */ avg(distinct a) from t;", "Plan": [ "HashAgg_16 1.00 root funcs:avg(distinct Column#7)->Column#5", - "└─Projection_17 8000.00 root cast(test.t.a, decimal(15,4) BINARY)->Column#7", + "└─Projection_17 8000.00 root cast(test.t.a, decimal(20,0) BINARY)->Column#7", " └─TableReader_18 8000.00 root data:HashAgg_19", " └─HashAgg_19 8000.00 cop[tikv] group by:test.t.a, ", " └─TableFullScan_15 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" @@ -611,7 +611,7 @@ "SQL": "select /*+ HASH_AGG(), AGG_TO_COP() */ avg(distinct a) from t;", "Plan": [ "HashAgg_8 1.00 root funcs:avg(distinct Column#6)->Column#5", - "└─Projection_9 10000.00 root cast(test.t.a, decimal(15,4) BINARY)->Column#6", + "└─Projection_9 10000.00 root cast(test.t.a, decimal(20,0) BINARY)->Column#6", " └─TableReader_10 10000.00 root data:TableFullScan_11", " └─TableFullScan_11 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(10,0) BINARY)->Column#11, test.t.c, test.t.c", + " └─Projection_10 10000.00 root cast(test.t.b, decimal(20,0) 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/cascades/testdata/transformation_rules_suite_out.json b/planner/cascades/testdata/transformation_rules_suite_out.json index 6324f66d98f21..5a9bc5b01f38b 100644 --- a/planner/cascades/testdata/transformation_rules_suite_out.json +++ b/planner/cascades/testdata/transformation_rules_suite_out.json @@ -2344,7 +2344,7 @@ "Group#2 Schema:[Column#13,Column#14,Column#15,test.t.b,Column#16,Column#17,Column#18,Column#19,Column#20,Column#14,Column#13]", " Selection_4 input:[Group#3], ge(Column#13, 0), ge(Column#14, 0)", "Group#3 Schema:[Column#13,Column#14,Column#15,test.t.b,Column#16,Column#17,Column#18,Column#19,Column#20,Column#14,Column#13]", - " Projection_8 input:[Group#4], 1->Column#13, cast(test.t.b, decimal(65,0) BINARY)->Column#14, cast(test.t.b, decimal(15,4) BINARY)->Column#15, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#20, cast(test.t.b, decimal(65,0) BINARY)->Column#14, 1->Column#13", + " Projection_8 input:[Group#4], 1->Column#13, cast(test.t.b, decimal(65,0) BINARY)->Column#14, cast(test.t.b, decimal(20,0) BINARY)->Column#15, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#20, cast(test.t.b, decimal(65,0) BINARY)->Column#14, 1->Column#13", "Group#4 Schema:[test.t.a,test.t.b], UniqueKey:[test.t.a]", " DataSource_1 table:t" ] @@ -2353,7 +2353,7 @@ "SQL": "select count(b), sum(b), avg(b), f, max(c), min(c), bit_and(c), bit_or(d), bit_xor(g) from t group by a", "Result": [ "Group#0 Schema:[Column#13,Column#14,Column#15,test.t.f,Column#16,Column#17,Column#18,Column#19,Column#20]", - " Projection_5 input:[Group#1], 1->Column#13, cast(test.t.b, decimal(65,0) BINARY)->Column#14, cast(test.t.b, decimal(15,4) BINARY)->Column#15, test.t.f, test.t.c, test.t.c, ifnull(cast(test.t.c, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.d, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.g, bigint(21) UNSIGNED BINARY), 0)->Column#20", + " Projection_5 input:[Group#1], 1->Column#13, cast(test.t.b, decimal(65,0) BINARY)->Column#14, cast(test.t.b, decimal(20,0) BINARY)->Column#15, test.t.f, test.t.c, test.t.c, ifnull(cast(test.t.c, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.d, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.g, bigint(21) UNSIGNED BINARY), 0)->Column#20", "Group#1 Schema:[test.t.a,test.t.b,test.t.c,test.t.d,test.t.f,test.t.g], UniqueKey:[test.t.f,test.t.f,test.t.g,test.t.a]", " DataSource_1 table:t" ] @@ -2429,7 +2429,7 @@ "Group#1 Schema:[Column#13,Column#14,Column#15]", " Aggregation_5 input:[Group#2], group by:Column#17, funcs:max(test.t.a), min(test.t.b), avg(Column#16)", "Group#2 Schema:[test.t.a,test.t.b,Column#16,Column#17]", - " Projection_4 input:[Group#3], test.t.a, test.t.b, cast(test.t.c, decimal(15,4) BINARY)->Column#16, plus(test.t.a, test.t.b)->Column#17", + " Projection_4 input:[Group#3], test.t.a, test.t.b, cast(test.t.c, decimal(20,0) BINARY)->Column#16, plus(test.t.a, test.t.b)->Column#17", "Group#3 Schema:[test.t.a,test.t.b,test.t.c]", " DataSource_1 table:t" ] diff --git a/planner/core/testdata/plan_suite_out.json b/planner/core/testdata/plan_suite_out.json index b46dfe15b6b7a..dd974907d18e1 100644 --- a/planner/core/testdata/plan_suite_out.json +++ b/planner/core/testdata/plan_suite_out.json @@ -1876,7 +1876,7 @@ "SQL": "select /*+ HASH_AGG() */ avg(distinct a) from t;", "Plan": [ "HashAgg 1.00 root funcs:avg(distinct Column#6)->Column#5", - "└─Projection 1.00 root cast(test.t.a, decimal(15,4) BINARY)->Column#6", + "└─Projection 1.00 root cast(test.t.a, decimal(20,0) BINARY)->Column#6", " └─TableReader 1.00 root data:HashAgg", " └─HashAgg 1.00 cop[tikv] group by:test.t.a, ", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" @@ -2038,7 +2038,7 @@ "SQL": "select /*+ HASH_AGG(), AGG_TO_COP() */ avg(distinct a) from t;", "Plan": [ "HashAgg 1.00 root funcs:avg(distinct Column#6)->Column#5", - "└─Projection 10000.00 root cast(test.t.a, decimal(15,4) BINARY)->Column#6", + "└─Projection 10000.00 root cast(test.t.a, decimal(20,0) BINARY)->Column#6", " └─TableReader 10000.00 root data:TableFullScan", " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo" ], @@ -2063,7 +2063,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(10,0) BINARY)->Column#15, test.t.c, test.t.c", + " └─Projection 10000.00 root cast(test.t.b, decimal(20,0) 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" ], @@ -2984,7 +2984,7 @@ "Plan": [ "Projection 8000.00 root test.t.d, Column#6, cast(Column#11, bigint(21) BINARY)->Column#7, Column#8", "└─HashAgg 8000.00 root group by:Column#20, funcs:sum(Column#16)->Column#6, funcs:sum(Column#17)->Column#11, funcs:avg(Column#18)->Column#8, funcs:firstrow(Column#19)->test.t.d", - " └─Projection 8000.00 root Column#9, cast(Column#10, decimal(20,0) BINARY)->Column#17, cast(test.t.c, decimal(15,4) BINARY)->Column#18, test.t.d, test.t.d", + " └─Projection 8000.00 root Column#9, cast(Column#10, decimal(20,0) BINARY)->Column#17, cast(test.t.c, decimal(20,0) BINARY)->Column#18, test.t.d, test.t.d", " └─HashAgg 8000.00 root group by:test.t.c, test.t.d, funcs:sum(Column#12)->Column#9, funcs:count(Column#13)->Column#10, funcs:firstrow(test.t.c)->test.t.c, funcs:firstrow(test.t.d)->test.t.d", " └─TableReader 8000.00 root data:HashAgg", " └─HashAgg 8000.00 cop[tikv] group by:test.t.c, test.t.d, funcs:sum(test.t.a)->Column#12, funcs:count(test.t.b)->Column#13", diff --git a/planner/core/testdata/plan_suite_unexported_out.json b/planner/core/testdata/plan_suite_unexported_out.json index ce05997328fde..3903a52c5db43 100644 --- a/planner/core/testdata/plan_suite_unexported_out.json +++ b/planner/core/testdata/plan_suite_unexported_out.json @@ -203,11 +203,11 @@ { "Name": "TestWindowFunction", "Cases": [ - "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))->Sort->Window(avg(cast(test.t.a, decimal(15,4) BINARY))->Column#14 over(partition by test.t.b))->Projection", + "TableReader(Table(t))->Window(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.a))->Projection", + "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.b))->Projection", "IndexReader(Index(t.f)[[NULL,+inf]])->Projection->Sort->Window(avg(cast(Column#16, decimal(24,4) BINARY))->Column#17 over(partition by Column#15))->Projection", - "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", + "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) 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(20,0) 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(10,0) BINARY))->Column#14 over())->Sort->Projection", "IndexReader(Index(t.f)[[NULL,+inf]]->StreamAgg)->StreamAgg->Window(sum(Column#13)->Column#15 over())->Projection", @@ -226,7 +226,7 @@ "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(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.a))->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.", @@ -247,7 +247,7 @@ "[planner:1210]Incorrect arguments to nth_value", "[planner:1210]Incorrect arguments to ntile", "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))->Sort->Window(avg(cast(test.t.a, decimal(20,0) 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(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.'", @@ -276,11 +276,11 @@ { "Name": "TestWindowParallelFunction", "Cases": [ - "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))->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(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.a))->Projection", + "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.b))->Partition(execution info: concurrency:4, data sources:[TableReader_10])->Projection", "IndexReader(Index(t.f)[[NULL,+inf]])->Projection->Sort->Window(avg(cast(Column#16, decimal(24,4) BINARY))->Column#17 over(partition by Column#15))->Partition(execution info: concurrency:4, data sources:[Projection_8])->Projection", - "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", + "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) 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(20,0) 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(10,0) BINARY))->Column#14 over())->Sort->Projection", "IndexReader(Index(t.f)[[NULL,+inf]]->StreamAgg)->StreamAgg->Window(sum(Column#13)->Column#15 over())->Projection", @@ -299,7 +299,7 @@ "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(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.a))->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.", @@ -320,7 +320,7 @@ "[planner:1210]Incorrect arguments to nth_value", "[planner:1210]Incorrect arguments to ntile", "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))->Sort->Window(avg(cast(test.t.a, decimal(20,0) 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(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.'", diff --git a/planner/core/testdata/window_push_down_suite_out.json b/planner/core/testdata/window_push_down_suite_out.json index 742a302cab348..c6fbaed458ce1 100644 --- a/planner/core/testdata/window_push_down_suite_out.json +++ b/planner/core/testdata/window_push_down_suite_out.json @@ -271,7 +271,7 @@ { "SQL": "explain select *, avg(empid) over () FROM employee", "Plan": [ - "Window_8 10000.00 root avg(cast(test.employee.empid, decimal(15,4) BINARY))->Column#6 over()", + "Window_8 10000.00 root avg(cast(test.employee.empid, decimal(20,0) BINARY))->Column#6 over()", "└─TableReader_12 10000.00 root data:TableFullScan_11", " └─TableFullScan_11 10000.00 cop[tiflash] table:employee keep order:false, stats:pseudo" ], From d7168995786d83fad177966fbb55631b046f9af1 Mon Sep 17 00:00:00 2001 From: xufei Date: Thu, 21 Jul 2022 18:12:18 +0800 Subject: [PATCH 4/8] update tests Signed-off-by: xufei --- expression/aggregation/agg_to_pb_test.go | 2 +- planner/cascades/testdata/integration_suite_out.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/expression/aggregation/agg_to_pb_test.go b/expression/aggregation/agg_to_pb_test.go index 45251badf2f9e..b90c115c4d4cf 100644 --- a/expression/aggregation/agg_to_pb_test.go +++ b/expression/aggregation/agg_to_pb_test.go @@ -53,7 +53,7 @@ func TestAggFunc2Pb(t *testing.T) { jsons := []string{ `{"tp":3002,"children":[{"tp":201,"val":"gAAAAAAAAAE=","sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":false}],"sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":%v,"aggFuncMode":0}`, - `{"tp":3001,"children":[{"tp":201,"val":"gAAAAAAAAAE=","sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":false}],"sig":0,"field_type":{"tp":8,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":%v,"aggFuncMode":0}`, + `{"tp":3001,"children":[{"tp":201,"val":"gAAAAAAAAAE=","sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":false}],"sig":0,"field_type":{"tp":8,"flag":0,"flen":20,"decimal":0,"collate":-63,"charset":"binary"},"has_distinct":%v,"aggFuncMode":0}`, `{"tp":3003,"children":[{"tp":201,"val":"gAAAAAAAAAE=","sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":false}],"sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":%v,"aggFuncMode":0}`, `{"tp":3007,"val":"AAAAAAAABAA=","children":[{"tp":201,"val":"gAAAAAAAAAE=","sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":false}],"sig":0,"field_type":{"tp":15,"flag":0,"flen":-1,"decimal":-1,"collate":-46,"charset":"utf8mb4"},"has_distinct":%v,"aggFuncMode":0}`, `{"tp":3005,"children":[{"tp":201,"val":"gAAAAAAAAAE=","sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":false}],"sig":0,"field_type":{"tp":5,"flag":0,"flen":-1,"decimal":-1,"collate":-63,"charset":"binary"},"has_distinct":%v,"aggFuncMode":0}`, diff --git a/planner/cascades/testdata/integration_suite_out.json b/planner/cascades/testdata/integration_suite_out.json index 7c56001885264..e76216732f3ab 100644 --- a/planner/cascades/testdata/integration_suite_out.json +++ b/planner/cascades/testdata/integration_suite_out.json @@ -393,7 +393,7 @@ "Plan": [ "HashAgg_18 1.00 root funcs:sum(Column#4)->Column#3", "└─TableReader_19 1.00 root data:HashAgg_20", - " └─HashAgg_20 1.00 cop[tikv] funcs:sum(cast(test.t.b, decimal(33,1) BINARY))->Column#4", + " └─HashAgg_20 1.00 cop[tikv] funcs:sum(cast(test.t.b, decimal(20,0) BINARY))->Column#4", " └─TableRangeScan_17 250.00 cop[tikv] table:t range:(0,1000], keep order:false, stats:pseudo" ], "Result": [ From 2430d48ea33bc1026c4b145a4ae74d5a4877d9ad Mon Sep 17 00:00:00 2001 From: xufei Date: Fri, 22 Jul 2022 09:40:11 +0800 Subject: [PATCH 5/8] fix ci Signed-off-by: xufei --- .../testdata/integration_suite_out.json | 2 +- .../transformation_rules_suite_out.json | 66 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/planner/cascades/testdata/integration_suite_out.json b/planner/cascades/testdata/integration_suite_out.json index e76216732f3ab..12055c7c4f3c7 100644 --- a/planner/cascades/testdata/integration_suite_out.json +++ b/planner/cascades/testdata/integration_suite_out.json @@ -450,7 +450,7 @@ "SQL": "select count(b), sum(b), avg(b), b, max(b), min(b), bit_and(b), bit_or(b), bit_xor(b) from t group by a having sum(b) >= 0 and count(b) >= 0 order by b", "Plan": [ "Projection_13 8000.00 root Column#3, Column#4, Column#5, test.t.b, Column#6, Column#7, Column#8, Column#9, Column#10", - "└─Projection_15 8000.00 root if(isnull(test.t.b), 0, 1)->Column#3, cast(test.t.b, decimal(32,0) BINARY)->Column#4, cast(test.t.b, decimal(20,0) BINARY)->Column#5, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#8, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#9, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#10, cast(test.t.b, decimal(32,0) BINARY)->Column#4, if(isnull(test.t.b), 0, 1)->Column#3", + "└─Projection_15 8000.00 root if(isnull(test.t.b), 0, 1)->Column#3, cast(test.t.b, decimal(32,0) BINARY)->Column#4, cast(test.t.b, decimal(15,4) BINARY)->Column#5, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#8, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#9, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#10, cast(test.t.b, decimal(32,0) BINARY)->Column#4, if(isnull(test.t.b), 0, 1)->Column#3", " └─Sort_22 8000.00 root test.t.b", " └─TableReader_19 8000.00 root data:Selection_20", " └─Selection_20 8000.00 cop[tikv] ge(cast(test.t.b, decimal(32,0) BINARY), 0), ge(if(isnull(test.t.b), 0, 1), 0)", diff --git a/planner/cascades/testdata/transformation_rules_suite_out.json b/planner/cascades/testdata/transformation_rules_suite_out.json index 5a9bc5b01f38b..18ffd0adedbc9 100644 --- a/planner/cascades/testdata/transformation_rules_suite_out.json +++ b/planner/cascades/testdata/transformation_rules_suite_out.json @@ -1012,57 +1012,57 @@ "Group#1 Schema:[Column#26]", " Union_7 input:[Group#2,Group#3]", "Group#2 Schema:[Column#26]", - " Projection_8 input:[Group#4], cast(test.t.a, decimal(65,0) BINARY)->Column#26", + " Projection_8 input:[Group#4], cast(test.t.a, decimal(32,0) BINARY)->Column#26", "Group#4 Schema:[test.t.a]", " Projection_2 input:[Group#5], test.t.a", "Group#5 Schema:[test.t.a]", - " TopN_15 input:[Group#6], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", - " TopN_15 input:[Group#7], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", - " TopN_15 input:[Group#8], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", - " TopN_15 input:[Group#9], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", - " TopN_15 input:[Group#10], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", - " TopN_15 input:[Group#11], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", - " TopN_15 input:[Group#12], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_15 input:[Group#6], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", + " TopN_15 input:[Group#7], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", + " TopN_15 input:[Group#8], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", + " TopN_15 input:[Group#9], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", + " TopN_15 input:[Group#10], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", + " TopN_15 input:[Group#11], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", + " TopN_15 input:[Group#12], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#6 Schema:[test.t.a]", " TiKVSingleGather_21 input:[Group#13], table:t, index:c_d_e", "Group#13 Schema:[test.t.a]", - " TopN_38 input:[Group#14], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_38 input:[Group#14], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#14 Schema:[test.t.a]", " IndexScan_20 table:t, index:c, d, e", "Group#7 Schema:[test.t.a]", " TiKVSingleGather_23 input:[Group#15], table:t, index:f", "Group#15 Schema:[test.t.a]", - " TopN_37 input:[Group#16], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_37 input:[Group#16], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#16 Schema:[test.t.a]", " IndexScan_22 table:t, index:f", "Group#8 Schema:[test.t.a]", " TiKVSingleGather_25 input:[Group#17], table:t, index:g", "Group#17 Schema:[test.t.a]", - " TopN_36 input:[Group#18], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_36 input:[Group#18], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#18 Schema:[test.t.a]", " IndexScan_24 table:t, index:g", "Group#9 Schema:[test.t.a]", " TiKVSingleGather_27 input:[Group#19], table:t, index:f_g", "Group#19 Schema:[test.t.a]", - " TopN_35 input:[Group#20], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_35 input:[Group#20], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#20 Schema:[test.t.a]", " IndexScan_26 table:t, index:f, g", "Group#10 Schema:[test.t.a]", " TiKVSingleGather_29 input:[Group#21], table:t, index:c_d_e_str", "Group#21 Schema:[test.t.a]", - " TopN_34 input:[Group#22], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_34 input:[Group#22], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#22 Schema:[test.t.a]", " IndexScan_28 table:t, index:c_str, d_str, e_str", "Group#11 Schema:[test.t.a]", " TiKVSingleGather_31 input:[Group#23], table:t, index:e_d_c_str_prefix", "Group#23 Schema:[test.t.a]", - " TopN_33 input:[Group#24], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_33 input:[Group#24], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#24 Schema:[test.t.a]", " IndexScan_30 table:t, index:e_str, d_str, c_str", "Group#12 Schema:[test.t.a]", " TiKVSingleGather_19 input:[Group#25], table:t", "Group#25 Schema:[test.t.a]", - " TopN_32 input:[Group#26], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:2", + " TopN_32 input:[Group#26], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:2", "Group#26 Schema:[test.t.a]", " TableScan_18 table:t, pk col:test.t.a", "Group#3 Schema:[Column#26]", @@ -1089,57 +1089,57 @@ "Group#1 Schema:[Column#26]", " Union_7 input:[Group#2,Group#3]", "Group#2 Schema:[Column#26]", - " Projection_8 input:[Group#4], cast(test.t.a, decimal(65,0) BINARY)->Column#26", + " Projection_8 input:[Group#4], cast(test.t.a, decimal(32,0) BINARY)->Column#26", "Group#4 Schema:[test.t.a]", " Projection_2 input:[Group#5], test.t.a", "Group#5 Schema:[test.t.a]", - " TopN_15 input:[Group#6], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", - " TopN_15 input:[Group#7], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", - " TopN_15 input:[Group#8], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", - " TopN_15 input:[Group#9], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", - " TopN_15 input:[Group#10], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", - " TopN_15 input:[Group#11], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", - " TopN_15 input:[Group#12], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_15 input:[Group#6], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", + " TopN_15 input:[Group#7], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", + " TopN_15 input:[Group#8], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", + " TopN_15 input:[Group#9], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", + " TopN_15 input:[Group#10], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", + " TopN_15 input:[Group#11], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", + " TopN_15 input:[Group#12], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#6 Schema:[test.t.a]", " TiKVSingleGather_21 input:[Group#13], table:t, index:c_d_e", "Group#13 Schema:[test.t.a]", - " TopN_38 input:[Group#14], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_38 input:[Group#14], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#14 Schema:[test.t.a]", " IndexScan_20 table:t, index:c, d, e", "Group#7 Schema:[test.t.a]", " TiKVSingleGather_23 input:[Group#15], table:t, index:f", "Group#15 Schema:[test.t.a]", - " TopN_37 input:[Group#16], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_37 input:[Group#16], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#16 Schema:[test.t.a]", " IndexScan_22 table:t, index:f", "Group#8 Schema:[test.t.a]", " TiKVSingleGather_25 input:[Group#17], table:t, index:g", "Group#17 Schema:[test.t.a]", - " TopN_36 input:[Group#18], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_36 input:[Group#18], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#18 Schema:[test.t.a]", " IndexScan_24 table:t, index:g", "Group#9 Schema:[test.t.a]", " TiKVSingleGather_27 input:[Group#19], table:t, index:f_g", "Group#19 Schema:[test.t.a]", - " TopN_35 input:[Group#20], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_35 input:[Group#20], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#20 Schema:[test.t.a]", " IndexScan_26 table:t, index:f, g", "Group#10 Schema:[test.t.a]", " TiKVSingleGather_29 input:[Group#21], table:t, index:c_d_e_str", "Group#21 Schema:[test.t.a]", - " TopN_34 input:[Group#22], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_34 input:[Group#22], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#22 Schema:[test.t.a]", " IndexScan_28 table:t, index:c_str, d_str, e_str", "Group#11 Schema:[test.t.a]", " TiKVSingleGather_31 input:[Group#23], table:t, index:e_d_c_str_prefix", "Group#23 Schema:[test.t.a]", - " TopN_33 input:[Group#24], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_33 input:[Group#24], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#24 Schema:[test.t.a]", " IndexScan_30 table:t, index:e_str, d_str, c_str", "Group#12 Schema:[test.t.a]", " TiKVSingleGather_19 input:[Group#25], table:t", "Group#25 Schema:[test.t.a]", - " TopN_32 input:[Group#26], cast(test.t.a, decimal(65,0) BINARY), offset:0, count:3", + " TopN_32 input:[Group#26], cast(test.t.a, decimal(32,0) BINARY), offset:0, count:3", "Group#26 Schema:[test.t.a]", " TableScan_18 table:t, pk col:test.t.a", "Group#3 Schema:[Column#26]", @@ -2329,7 +2329,7 @@ "Group#1 Schema:[test.t.a,Column#13]", " Selection_4 input:[Group#2], gt(Column#13, 4)", "Group#2 Schema:[test.t.a,Column#13]", - " Projection_7 input:[Group#3], test.t.a, cast(test.t.b, decimal(65,0) BINARY)->Column#13", + " Projection_7 input:[Group#3], test.t.a, cast(test.t.b, decimal(32,0) BINARY)->Column#13", "Group#3 Schema:[test.t.a,test.t.b], UniqueKey:[test.t.a]", " DataSource_1 table:t" ] @@ -2344,7 +2344,7 @@ "Group#2 Schema:[Column#13,Column#14,Column#15,test.t.b,Column#16,Column#17,Column#18,Column#19,Column#20,Column#14,Column#13]", " Selection_4 input:[Group#3], ge(Column#13, 0), ge(Column#14, 0)", "Group#3 Schema:[Column#13,Column#14,Column#15,test.t.b,Column#16,Column#17,Column#18,Column#19,Column#20,Column#14,Column#13]", - " Projection_8 input:[Group#4], 1->Column#13, cast(test.t.b, decimal(65,0) BINARY)->Column#14, cast(test.t.b, decimal(20,0) BINARY)->Column#15, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#20, cast(test.t.b, decimal(65,0) BINARY)->Column#14, 1->Column#13", + " Projection_8 input:[Group#4], 1->Column#13, cast(test.t.b, decimal(32,0) BINARY)->Column#14, cast(test.t.b, decimal(15,4) BINARY)->Column#15, test.t.b, test.t.b, test.t.b, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.b, bigint(21) UNSIGNED BINARY), 0)->Column#20, cast(test.t.b, decimal(32,0) BINARY)->Column#14, 1->Column#13", "Group#4 Schema:[test.t.a,test.t.b], UniqueKey:[test.t.a]", " DataSource_1 table:t" ] @@ -2353,7 +2353,7 @@ "SQL": "select count(b), sum(b), avg(b), f, max(c), min(c), bit_and(c), bit_or(d), bit_xor(g) from t group by a", "Result": [ "Group#0 Schema:[Column#13,Column#14,Column#15,test.t.f,Column#16,Column#17,Column#18,Column#19,Column#20]", - " Projection_5 input:[Group#1], 1->Column#13, cast(test.t.b, decimal(65,0) BINARY)->Column#14, cast(test.t.b, decimal(20,0) BINARY)->Column#15, test.t.f, test.t.c, test.t.c, ifnull(cast(test.t.c, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.d, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.g, bigint(21) UNSIGNED BINARY), 0)->Column#20", + " Projection_5 input:[Group#1], 1->Column#13, cast(test.t.b, decimal(32,0) BINARY)->Column#14, cast(test.t.b, decimal(15,4) BINARY)->Column#15, test.t.f, test.t.c, test.t.c, ifnull(cast(test.t.c, bigint(21) UNSIGNED BINARY), 18446744073709551615)->Column#18, ifnull(cast(test.t.d, bigint(21) UNSIGNED BINARY), 0)->Column#19, ifnull(cast(test.t.g, bigint(21) UNSIGNED BINARY), 0)->Column#20", "Group#1 Schema:[test.t.a,test.t.b,test.t.c,test.t.d,test.t.f,test.t.g], UniqueKey:[test.t.f,test.t.f,test.t.g,test.t.a]", " DataSource_1 table:t" ] From 2176290ce14c618c47cca25acbf8148cf6e648e8 Mon Sep 17 00:00:00 2001 From: xufei Date: Fri, 22 Jul 2022 11:51:50 +0800 Subject: [PATCH 6/8] fix ci Signed-off-by: xufei --- expression/expr_to_pb_test.go | 56 +++++++++---------- planner/core/plan_to_pb_test.go | 2 +- .../core/testdata/enforce_mpp_suite_out.json | 4 +- .../core/testdata/integration_suite_out.json | 32 +++++------ .../testdata/plan_suite_unexported_out.json | 4 +- types/field_type.go | 6 +- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/expression/expr_to_pb_test.go b/expression/expr_to_pb_test.go index a9507d1a325b6..b8aa3bf2f3aba 100644 --- a/expression/expr_to_pb_test.go +++ b/expression/expr_to_pb_test.go @@ -175,19 +175,19 @@ func TestColumn2Pb(t *testing.T) { pbExprs, err := ExpressionsToPBList(sc, colExprs, client) require.NoError(t, err) jsons := []string{ - "{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":2,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":201,\"val\":\"gAAAAAAAAAM=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":2,\"flag\":0,\"flen\":6,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":201,\"val\":\"gAAAAAAAAAM=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAAQ=\",\"sig\":0,\"field_type\":{\"tp\":4,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAAU=\",\"sig\":0,\"field_type\":{\"tp\":5,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAAY=\",\"sig\":0,\"field_type\":{\"tp\":6,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAAc=\",\"sig\":0,\"field_type\":{\"tp\":7,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":201,\"val\":\"gAAAAAAAAAg=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":201,\"val\":\"gAAAAAAAAAk=\",\"sig\":0,\"field_type\":{\"tp\":9,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":201,\"val\":\"gAAAAAAAAAg=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":201,\"val\":\"gAAAAAAAAAk=\",\"sig\":0,\"field_type\":{\"tp\":9,\"flag\":0,\"flen\":9,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAAo=\",\"sig\":0,\"field_type\":{\"tp\":10,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAAs=\",\"sig\":0,\"field_type\":{\"tp\":11,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAAw=\",\"sig\":0,\"field_type\":{\"tp\":12,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":201,\"val\":\"gAAAAAAAAA0=\",\"sig\":0,\"field_type\":{\"tp\":13,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":201,\"val\":\"gAAAAAAAAA0=\",\"sig\":0,\"field_type\":{\"tp\":13,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAAA8=\",\"sig\":0,\"field_type\":{\"tp\":15,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-46,\"charset\":\"utf8mb4\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAABA=\",\"sig\":0,\"field_type\":{\"tp\":245,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "{\"tp\":201,\"val\":\"gAAAAAAAABE=\",\"sig\":0,\"field_type\":{\"tp\":246,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", @@ -237,13 +237,13 @@ func TestCompareFunc2Pb(t *testing.T) { require.NoError(t, err) require.Len(t, pbExprs, len(compareExprs)) jsons := []string{ - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":100,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":110,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":120,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":130,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":140,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":150,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":160,\"field_type\":{\"tp\":8,\"flag\":524417,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":100,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":110,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":120,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":130,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":140,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":150,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":8,\"flag\":0,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":160,\"field_type\":{\"tp\":8,\"flag\":524417,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", } for i, pbExpr := range pbExprs { require.NotNil(t, pbExprs) @@ -382,10 +382,10 @@ func TestLogicalFunc2Pb(t *testing.T) { pbExprs, err := ExpressionsToPBList(sc, logicalFuncs, client) require.NoError(t, err) jsons := []string{ - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3101,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3102,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3103,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3104,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3101,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3102,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3103,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":1,\"flag\":0,\"flen\":4,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3104,\"field_type\":{\"tp\":8,\"flag\":524416,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", } for i, pbExpr := range pbExprs { js, err := json.Marshal(pbExpr) @@ -418,12 +418,12 @@ func TestBitwiseFunc2Pb(t *testing.T) { pbExprs, err := ExpressionsToPBList(sc, bitwiseFuncs, client) require.NoError(t, err) jsons := []string{ - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3118,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3119,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3120,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3129,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3130,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3121,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3118,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3119,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3120,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3129,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3130,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3121,\"field_type\":{\"tp\":8,\"flag\":160,\"flen\":20,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", } for i, pbExpr := range pbExprs { js, err := json.Marshal(pbExpr) @@ -461,9 +461,9 @@ func TestControlFunc2Pb(t *testing.T) { pbExprs, err := ExpressionsToPBList(sc, controlFuncs, client) require.NoError(t, err) jsons := []string{ - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAM=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4208,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":-1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAM=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4107,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":24,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4101,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":24,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAM=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4208,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAM=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4107,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false},{\"tp\":201,\"val\":\"gAAAAAAAAAI=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4101,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", "null", } for i, pbExpr := range pbExprs { @@ -493,8 +493,8 @@ func TestOtherFunc2Pb(t *testing.T) { pbExprs, err := ExpressionsToPBList(sc, otherFuncs, client) require.NoError(t, err) jsons := map[string]string{ - ast.Coalesce: "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4201,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":0,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", - ast.IsNull: "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":-1,\"decimal\":-1,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3116,\"field_type\":{\"tp\":8,\"flag\":524417,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + ast.Coalesce: "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":4201,\"field_type\":{\"tp\":3,\"flag\":128,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", + ast.IsNull: "{\"tp\":10000,\"children\":[{\"tp\":201,\"val\":\"gAAAAAAAAAE=\",\"sig\":0,\"field_type\":{\"tp\":3,\"flag\":0,\"flen\":11,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}],\"sig\":3116,\"field_type\":{\"tp\":8,\"flag\":524417,\"flen\":1,\"decimal\":0,\"collate\":-63,\"charset\":\"binary\"},\"has_distinct\":false}", } for i, pbExpr := range pbExprs { js, err := json.Marshal(pbExpr) diff --git a/planner/core/plan_to_pb_test.go b/planner/core/plan_to_pb_test.go index b4f1101528da7..2611039c63764 100644 --- a/planner/core/plan_to_pb_test.go +++ b/planner/core/plan_to_pb_test.go @@ -36,7 +36,7 @@ func TestColumnToProto(t *testing.T) { FieldType: *tp, } pc := util.ColumnToProto(col) - expect := &tipb.ColumnInfo{ColumnId: 0, Tp: 3, Collation: 83, ColumnLen: -1, Decimal: -1, Flag: 10, Elems: []string(nil), DefaultVal: []uint8(nil), PkHandle: false, XXX_unrecognized: []uint8(nil)} + expect := &tipb.ColumnInfo{ColumnId: 0, Tp: 3, Collation: 83, ColumnLen: 11, Decimal: 0, Flag: 10, Elems: []string(nil), DefaultVal: []uint8(nil), PkHandle: false, XXX_unrecognized: []uint8(nil)} require.Equal(t, expect, pc) cols := []*model.ColumnInfo{col, col} diff --git a/planner/core/testdata/enforce_mpp_suite_out.json b/planner/core/testdata/enforce_mpp_suite_out.json index 5a751c2158014..53069c4bd6a63 100644 --- a/planner/core/testdata/enforce_mpp_suite_out.json +++ b/planner/core/testdata/enforce_mpp_suite_out.json @@ -921,7 +921,7 @@ " └─ExchangeReceiver_55 8000.00 mpp[tiflash] ", " └─ExchangeSender_54 8000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.t.a, collate: binary]", " └─HashAgg_51 8000.00 mpp[tiflash] group by:Column#62, Column#63, funcs:sum(Column#58)->Column#48, funcs:count(Column#59)->Column#49, funcs:sum(Column#60)->Column#50, funcs:firstrow(Column#61)->Column#52", - " └─Projection_59 8000.00 mpp[tiflash] cast(Column#11, decimal(20,0) BINARY)->Column#58, test.t.c, cast(test.t.c, decimal(24,4) BINARY)->Column#60, test.t.d, date_format(test.t.d, %Y)->Column#62, test.t.a", + " └─Projection_59 8000.00 mpp[tiflash] cast(Column#11, decimal(20,0) BINARY)->Column#58, test.t.c, cast(test.t.c, decimal(20,0) BINARY)->Column#60, test.t.d, date_format(test.t.d, %Y)->Column#62, test.t.a", " └─Projection_38 8000.00 mpp[tiflash] Column#11, test.t.c, test.t.a, test.t.d", " └─HashAgg_39 8000.00 mpp[tiflash] group by:Column#28, test.t.a, test.t.c, funcs:sum(Column#29)->Column#11, funcs:firstrow(test.t.c)->test.t.c, funcs:firstrow(test.t.a)->test.t.a, funcs:firstrow(Column#32)->test.t.d", " └─ExchangeReceiver_41 8000.00 mpp[tiflash] ", @@ -950,7 +950,7 @@ "Plan": [ "Projection_4 8000.00 root test.t.a, Column#7, Column#8, Column#9", "└─HashAgg_6 8000.00 root group by:Column#14, funcs:count(Column#10)->Column#7, funcs:avg(distinct Column#11)->Column#8, funcs:count(distinct Column#12)->Column#9, funcs:firstrow(Column#13)->test.t.a", - " └─Projection_11 10000.00 root test.t.b, cast(test.t.c, decimal(24,4) BINARY)->Column#11, test.t.c, test.t.a, test.t.a", + " └─Projection_11 10000.00 root test.t.b, cast(test.t.c, decimal(20,0) BINARY)->Column#11, test.t.c, test.t.a, test.t.a", " └─TableReader_10 10000.00 root data:TableFullScan_9", " └─TableFullScan_9 10000.00 cop[tiflash] table:t keep order:false, stats:pseudo" ], diff --git a/planner/core/testdata/integration_suite_out.json b/planner/core/testdata/integration_suite_out.json index 169e84f602275..1c0da60e83adb 100644 --- a/planner/core/testdata/integration_suite_out.json +++ b/planner/core/testdata/integration_suite_out.json @@ -4129,7 +4129,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(14,4) BINARY)->Column#10", + " └─Projection 10000.00 batchCop[tiflash] test.t.a, cast(test.t.a, decimal(10,0) BINARY)->Column#10", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null @@ -4140,7 +4140,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(14,4) BINARY)->Column#10", + " └─Projection 10000.00 batchCop[tiflash] test.t.a, cast(test.t.a, decimal(10,0) BINARY)->Column#10", " └─TableFullScan 10000.00 batchCop[tiflash] table:t keep order:false, stats:pseudo" ], "Warn": null @@ -6442,7 +6442,7 @@ "└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 mpp[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 mpp[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 mpp[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", + " └─Projection 10000.00 mpp[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(10,0) BINARY)->Column#19, test.ts.col_2", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: utf8mb4_bin]", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6458,7 +6458,7 @@ "└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 mpp[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#19, 0), 1, Column#19), decimal(20,0) BINARY))->Column#8", " └─HashAgg 8000.00 mpp[tiflash] group by:Column#32, funcs:group_concat(distinct Column#25, Column#26, Column#27 order by Column#28 separator \",\")->Column#5, funcs:count(1)->Column#6, funcs:max(Column#29)->Column#7, funcs:count(Column#30)->Column#19, funcs:sum(Column#31)->Column#8", - " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#27, test.ts.col_0, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#31, test.ts.col_2", + " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#27, test.ts.col_0, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(10,0) BINARY)->Column#31, test.ts.col_2", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: utf8mb4_bin]", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6474,7 +6474,7 @@ "└─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 1.00 mpp[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 mpp[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 mpp[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", + " └─Projection 10000.00 mpp[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(10,0) BINARY)->Column#18", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: PassThrough", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6494,7 +6494,7 @@ " └─ExchangeReceiver 1.00 mpp[tiflash] ", " └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 mpp[tiflash] group by:Column#23, Column#24, Column#25, funcs:count(Column#19)->Column#15, funcs:max(Column#20)->Column#16, funcs:count(Column#21)->Column#17, funcs:sum(Column#22)->Column#18", - " └─Projection 10000.00 mpp[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#22, test.ts.col_0, test.ts.col_1, test.ts.id", + " └─Projection 10000.00 mpp[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(10,0) BINARY)->Column#22, test.ts.col_0, test.ts.col_1, test.ts.id", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -6508,7 +6508,7 @@ "└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 mpp[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#26, 0), 1, Column#26), decimal(20,0) BINARY))->Column#8", " └─HashAgg 8000.00 mpp[tiflash] group by:Column#40, funcs:group_concat(Column#33, Column#34, Column#35 separator \",\")->Column#5, funcs:count(Column#36)->Column#6, funcs:min(Column#37)->Column#7, funcs:count(Column#38)->Column#26, funcs:sum(Column#39)->Column#8", - " └─Projection 10000.00 mpp[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", + " └─Projection 10000.00 mpp[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(10,0) BINARY)->Column#39, test.ts.col_2", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: utf8mb4_bin]", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6524,7 +6524,7 @@ "└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 mpp[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#19, 0), 1, Column#19), decimal(20,0) BINARY))->Column#8", " └─HashAgg 8000.00 mpp[tiflash] group by:Column#32, funcs:group_concat(distinct Column#25, Column#26, Column#27 separator \",\")->Column#5, funcs:count(Column#28)->Column#6, funcs:max(Column#29)->Column#7, funcs:count(Column#30)->Column#19, funcs:sum(Column#31)->Column#8", - " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#27, test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#31, test.ts.col_2", + " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#27, test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(10,0) BINARY)->Column#31, test.ts.col_2", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: utf8mb4_bin]", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6540,7 +6540,7 @@ "└─TableReader 1.00 root data:ExchangeSender", " └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 mpp[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 mpp[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", + " └─Projection 10000.00 mpp[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(10,0) BINARY)->Column#30", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -6558,7 +6558,7 @@ " └─ExchangeReceiver 1.00 mpp[tiflash] ", " └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 mpp[tiflash] group by:Column#23, Column#24, Column#25, funcs:count(Column#19)->Column#15, funcs:max(Column#20)->Column#16, funcs:count(Column#21)->Column#17, funcs:sum(Column#22)->Column#18", - " └─Projection 10000.00 mpp[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#22, test.ts.col_0, test.ts.col_1, test.ts.id", + " └─Projection 10000.00 mpp[tiflash] test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(10,0) BINARY)->Column#22, test.ts.col_0, test.ts.col_1, test.ts.id", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -6572,7 +6572,7 @@ "└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 mpp[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 mpp[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 mpp[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", + " └─Projection 10000.00 mpp[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(10,0) BINARY)->Column#28, test.ts.col_2", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: utf8mb4_bin]", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6588,7 +6588,7 @@ "└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 mpp[tiflash] Column#5, Column#6, Column#7, div(Column#8, cast(case(eq(Column#13, 0), 1, Column#13), decimal(20,0) BINARY))->Column#8", " └─HashAgg 8000.00 mpp[tiflash] group by:Column#24, funcs:group_concat(distinct Column#16 separator \",\")->Column#5, funcs:count(Column#17)->Column#6, funcs:group_concat(Column#18, Column#19 order by Column#20, Column#21 separator \",\")->Column#7, funcs:count(Column#22)->Column#13, funcs:sum(Column#23)->Column#8", - " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#19, test.ts.col_1, test.ts.id, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#23, test.ts.col_2", + " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#19, test.ts.col_1, test.ts.id, test.ts.id, cast(test.ts.id, decimal(10,0) BINARY)->Column#23, test.ts.col_2", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_2, collate: utf8mb4_bin]", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6604,7 +6604,7 @@ "└─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 1.00 mpp[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 mpp[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 mpp[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", + " └─Projection 10000.00 mpp[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(10,0) BINARY)->Column#27", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: PassThrough", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6620,7 +6620,7 @@ "└─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 1.00 mpp[tiflash] Column#5, Column#6, Column#7, Column#8, div(Column#9, cast(case(eq(Column#12, 0), 1, Column#12), decimal(20,0) BINARY))->Column#9", " └─HashAgg 1.00 mpp[tiflash] funcs:group_concat(distinct Column#14, Column#15, Column#16 separator \",\")->Column#5, funcs:count(Column#17)->Column#6, funcs:group_concat(Column#18, Column#19 order by Column#20, Column#21 separator \",\")->Column#7, funcs:max(Column#22)->Column#8, funcs:count(Column#23)->Column#12, funcs:sum(Column#24)->Column#9", - " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#16, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#19, test.ts.col_1, test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#24", + " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#16, test.ts.id, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#19, test.ts.col_1, test.ts.id, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(10,0) BINARY)->Column#24", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: PassThrough", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" @@ -6640,7 +6640,7 @@ " └─ExchangeReceiver 1.00 mpp[tiflash] ", " └─ExchangeSender 1.00 mpp[tiflash] ExchangeType: PassThrough", " └─HashAgg 1.00 mpp[tiflash] group by:Column#25, Column#26, Column#27, Column#28, funcs:group_concat(Column#20, Column#21 separator \",\")->Column#16, funcs:max(Column#22)->Column#17, funcs:count(Column#23)->Column#18, funcs:sum(Column#24)->Column#19", - " └─Projection 10000.00 mpp[tiflash] test.ts.col_1, cast(test.ts.id, var_string(20))->Column#21, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(14,4) BINARY)->Column#24, test.ts.col_0, test.ts.col_1, test.ts.id, test.ts.col_2", + " └─Projection 10000.00 mpp[tiflash] test.ts.col_1, cast(test.ts.id, var_string(20))->Column#21, test.ts.col_1, test.ts.id, cast(test.ts.id, decimal(10,0) BINARY)->Column#24, test.ts.col_0, test.ts.col_1, test.ts.id, test.ts.col_2", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" ], "Warning": [ @@ -6654,7 +6654,7 @@ "└─ExchangeSender 8000.00 mpp[tiflash] ExchangeType: PassThrough", " └─Projection 8000.00 mpp[tiflash] Column#5, Column#6, Column#7, Column#8, div(Column#9, cast(case(eq(Column#20, 0), 1, Column#20), decimal(20,0) BINARY))->Column#9", " └─HashAgg 8000.00 mpp[tiflash] group by:Column#35, funcs:group_concat(distinct Column#26, Column#27, Column#28 separator \",\")->Column#5, funcs:count(distinct Column#29)->Column#6, funcs:group_concat(Column#30, Column#31 separator \",\")->Column#7, funcs:max(Column#32)->Column#8, funcs:count(Column#33)->Column#20, funcs:sum(Column#34)->Column#9", - " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#28, test.ts.col_2, 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", + " └─Projection 10000.00 mpp[tiflash] test.ts.col_0, test.ts.col_1, cast(test.ts.id, var_string(20))->Column#28, test.ts.col_2, 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(10,0) BINARY)->Column#34, test.ts.col_0", " └─ExchangeReceiver 10000.00 mpp[tiflash] ", " └─ExchangeSender 10000.00 mpp[tiflash] ExchangeType: HashPartition, Hash Cols: [name: test.ts.col_0, collate: utf8mb4_bin]", " └─TableFullScan 10000.00 mpp[tiflash] table:ts keep order:false, stats:pseudo" diff --git a/planner/core/testdata/plan_suite_unexported_out.json b/planner/core/testdata/plan_suite_unexported_out.json index 3903a52c5db43..e34e9bb550f55 100644 --- a/planner/core/testdata/plan_suite_unexported_out.json +++ b/planner/core/testdata/plan_suite_unexported_out.json @@ -205,7 +205,7 @@ "Cases": [ "TableReader(Table(t))->Window(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.a))->Projection", "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.b))->Projection", - "IndexReader(Index(t.f)[[NULL,+inf]])->Projection->Sort->Window(avg(cast(Column#16, decimal(24,4) BINARY))->Column#17 over(partition by Column#15))->Projection", + "IndexReader(Index(t.f)[[NULL,+inf]])->Projection->Sort->Window(avg(cast(Column#16, decimal(20,0) BINARY))->Column#17 over(partition by Column#15))->Projection", "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) 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(20,0) BINARY))->Column#14 over(partition by test.t.a))->Projection", "[planner:1054]Unknown column 'z' in 'field list'", @@ -278,7 +278,7 @@ "Cases": [ "TableReader(Table(t))->Window(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.a))->Projection", "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) BINARY))->Column#14 over(partition by test.t.b))->Partition(execution info: concurrency:4, data sources:[TableReader_10])->Projection", - "IndexReader(Index(t.f)[[NULL,+inf]])->Projection->Sort->Window(avg(cast(Column#16, decimal(24,4) BINARY))->Column#17 over(partition by Column#15))->Partition(execution info: concurrency:4, data sources:[Projection_8])->Projection", + "IndexReader(Index(t.f)[[NULL,+inf]])->Projection->Sort->Window(avg(cast(Column#16, decimal(20,0) BINARY))->Column#17 over(partition by Column#15))->Partition(execution info: concurrency:4, data sources:[Projection_8])->Projection", "TableReader(Table(t))->Sort->Window(avg(cast(test.t.a, decimal(20,0) 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(20,0) BINARY))->Column#14 over(partition by test.t.a))->Projection", "[planner:1054]Unknown column 'z' in 'field list'", diff --git a/types/field_type.go b/types/field_type.go index 12235ebd5b2a1..0cf5dae4c60a9 100644 --- a/types/field_type.go +++ b/types/field_type.go @@ -41,7 +41,7 @@ type FieldType = ast.FieldType // with a type and other information about field type. func NewFieldType(tp byte) *FieldType { charset1, collate1 := DefaultCharsetForType(tp) - flen, decimal := MaxFlenAndDecimalForType(tp) + flen, decimal := minFlenAndDecimalForType(tp) return NewFieldTypeBuilder(). SetType(tp). SetCharset(charset1). @@ -333,8 +333,8 @@ func DefaultTypeForValue(value interface{}, tp *FieldType, char string, collate } } -// MaxFlenAndDecimalForType returns the default flen/decimal for mysql type. -func MaxFlenAndDecimalForType(tp byte) (int, int) { +// minFlenAndDecimalForType returns the minimum flen/decimal that can hold all the data for `tp`. +func minFlenAndDecimalForType(tp byte) (int, int) { switch tp { case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong, mysql.TypeYear: return mysql.GetDefaultFieldLengthAndDecimal(tp) From b4038ed833ba626f3317cf104da79493799c6678 Mon Sep 17 00:00:00 2001 From: xufei Date: Fri, 22 Jul 2022 12:28:12 +0800 Subject: [PATCH 7/8] fix ci Signed-off-by: xufei --- planner/core/plan_to_pb_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planner/core/plan_to_pb_test.go b/planner/core/plan_to_pb_test.go index 2611039c63764..9ea55a23babdd 100644 --- a/planner/core/plan_to_pb_test.go +++ b/planner/core/plan_to_pb_test.go @@ -62,7 +62,7 @@ func TestColumnToProto(t *testing.T) { collate.SetNewCollationEnabledForTest(true) pc = util.ColumnToProto(col) - expect = &tipb.ColumnInfo{ColumnId: 0, Tp: 3, Collation: -83, ColumnLen: -1, Decimal: -1, Flag: 10, Elems: []string(nil), DefaultVal: []uint8(nil), PkHandle: false, XXX_unrecognized: []uint8(nil)} + expect = &tipb.ColumnInfo{ColumnId: 0, Tp: 3, Collation: -83, ColumnLen: 11, Decimal: 0, Flag: 10, Elems: []string(nil), DefaultVal: []uint8(nil), PkHandle: false, XXX_unrecognized: []uint8(nil)} require.Equal(t, expect, pc) pcs = util.ColumnsToProto(cols, true) for _, v := range pcs { From 3813b8cd0abd2c240db5ef42dd438bfc2e1df8c0 Mon Sep 17 00:00:00 2001 From: xufei Date: Fri, 22 Jul 2022 13:22:21 +0800 Subject: [PATCH 8/8] fix ut Signed-off-by: xufei --- planner/core/expression_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/planner/core/expression_test.go b/planner/core/expression_test.go index 7b45867e8138b..93ba50d2d5011 100644 --- a/planner/core/expression_test.go +++ b/planner/core/expression_test.go @@ -122,12 +122,16 @@ func TestCast(t *testing.T) { f.SetType(mysql.TypeString) f.SetCharset(charset.CharsetBin) + f.SetFlen(-1) + f.SetDecimal(-1) v, err = evalAstExpr(ctx, expr) require.NoError(t, err) testutil.DatumEqual(t, types.NewDatum([]byte("1")), v) f.SetType(mysql.TypeString) f.SetCharset(charset.CharsetUTF8) + f.SetFlen(-1) + f.SetDecimal(-1) v, err = evalAstExpr(ctx, expr) require.NoError(t, err) testutil.DatumEqual(t, types.NewDatum([]byte("1")), v)