Skip to content

Commit

Permalink
Merge branch 'release-6.2' into release-6.2-0b1ad27b1a6d
Browse files Browse the repository at this point in the history
  • Loading branch information
purelind authored Jul 22, 2022
2 parents 2b3ee2b + 08e450c commit 9559289
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion expression/aggregation/base_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (a *baseFuncDesc) typeInfer4BitFuncs(ctx sessionctx.Context) {
a.RetTp.SetFlen(21)
types.SetBinChsClnFlag(a.RetTp)
a.RetTp.AddFlag(mysql.UnsignedFlag | mysql.NotNullFlag)
// TODO: a.Args[0] = expression.WrapWithCastAsInt(ctx, a.Args[0])
a.Args[0] = expression.WrapWithCastAsInt(ctx, a.Args[0])
}

func (a *baseFuncDesc) typeInfer4JsonFuncs(ctx sessionctx.Context) {
Expand Down
21 changes: 21 additions & 0 deletions planner/core/expression_rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,24 @@ func TestMultiColInExpression(t *testing.T) {
tk.MustQuery(tt).Sort().Check(testkit.Rows(output[i].Res...))
}
}

func TestBitFuncsReturnType(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (a timestamp, b varbinary(32))")
tk.MustExec("insert into t values ('2006-08-27 21:57:57', 0x373037343631313230)")
tk.MustExec("analyze table t")
var input []string
var output []struct {
Plan []string
}

expressionRewriterSuiteData := plannercore.GetExpressionRewriterSuiteData()
expressionRewriterSuiteData.GetTestCases(t, &input, &output)
for i, tt := range input {
tk.MustQuery("explain format = 'brief' " + tt).Check(testkit.Rows(output[i].Plan...))
}
}
8 changes: 7 additions & 1 deletion planner/core/testdata/expression_rewriter_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
"select t1.a from t1 group by t1.a having (a, count(1)) in (select a, b from t2)",
"select t1.a from t1 group by t1.a having (a, count(1)) not in (select a, b from t2)"
]
},
{
"name": "TestBitFuncsReturnType",
"cases": [
"select bit_or(a * b) from t"
]
}
]
]
15 changes: 14 additions & 1 deletion planner/core/testdata/expression_rewriter_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,18 @@
]
}
]
},
{
"Name": "TestBitFuncsReturnType",
"Cases": [
{
"Plan": [
"StreamAgg 1.00 root funcs:bit_or(Column#6)->Column#4",
"└─TableReader 1.00 root data:StreamAgg",
" └─StreamAgg 1.00 cop[tikv] funcs:bit_or(cast(mul(cast(test.t.a, double BINARY), cast(test.t.b, double BINARY)), bigint(20) BINARY))->Column#6",
" └─TableFullScan 1.00 cop[tikv] table:t keep order:false"
]
}
]
}
]
]

0 comments on commit 9559289

Please sign in to comment.