Skip to content

Commit

Permalink
expression: remove useless ctx input in `newBaseBuiltinFuncWithFieldT…
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao authored Dec 13, 2023
1 parent e14f66f commit 0909112
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 1 addition & 4 deletions pkg/expression/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,7 @@ func newBaseBuiltinFuncWithFieldTypes(ctx sessionctx.Context, funcName string, a

// newBaseBuiltinFuncWithFieldType create BaseBuiltinFunc with FieldType charset and collation.
// do not check and compute collation.
func newBaseBuiltinFuncWithFieldType(ctx sessionctx.Context, tp *types.FieldType, args []Expression) (baseBuiltinFunc, error) {
if ctx == nil {
return baseBuiltinFunc{}, errors.New("unexpected nil session ctx")
}
func newBaseBuiltinFuncWithFieldType(tp *types.FieldType, args []Expression) (baseBuiltinFunc, error) {
bf := baseBuiltinFunc{
bufAllocator: newLocalColumnPool(),
childrenVectorizedOnce: new(sync.Once),
Expand Down
7 changes: 3 additions & 4 deletions pkg/expression/builtin_grouping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"fmt"
"testing"

"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/testkit/testutil"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/chunk"
Expand All @@ -39,12 +38,12 @@ func constructFieldType() types.FieldType {
return tp
}

func createGroupingFunc(ctx sessionctx.Context, args []Expression) (*BuiltinGroupingImplSig, error) {
func createGroupingFunc(args []Expression) (*BuiltinGroupingImplSig, error) {
// TODO We should use the commented codes after the completion of rollup
// argTp := []types.EvalType{types.ETInt}
tp := constructFieldType()
// bf, err := newBaseBuiltinFuncWithTp(ctx, groupingImplName, args, types.ETInt, argTp...)
bf, err := newBaseBuiltinFuncWithFieldType(ctx, &tp, args)
bf, err := newBaseBuiltinFuncWithFieldType(&tp, args)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -92,7 +91,7 @@ func TestGrouping(t *testing.T) {
comment := fmt.Sprintf(`for grouping = "%d", version = "%d", groupingIDs = "%v", expectRes = "%d"`, testCase.groupingID, testCase.mode, testCase.groupingIDs, testCase.expectResult)
args := datumsToConstants(types.MakeDatums(testCase.groupingID))

groupingFunc, err := createGroupingFunc(ctx, args)
groupingFunc, err := createGroupingFunc(args)
require.NoError(t, err, comment)

err = groupingFunc.SetMetadata(testCase.mode, []map[uint64]struct{}{testCase.groupingIDs})
Expand Down
2 changes: 1 addition & 1 deletion pkg/expression/distsql_builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func PbTypeToFieldType(tp *tipb.FieldType) *types.FieldType {

func getSignatureByPB(ctx sessionctx.Context, sigCode tipb.ScalarFuncSig, tp *tipb.FieldType, args []Expression) (f builtinFunc, e error) {
fieldTp := PbTypeToFieldType(tp)
base, err := newBaseBuiltinFuncWithFieldType(ctx, fieldTp, args)
base, err := newBaseBuiltinFuncWithFieldType(fieldTp, args)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 0909112

Please sign in to comment.