Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 committed Apr 18, 2019
1 parent 9a4c874 commit 55d7433
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion expression/scalar_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ func (sf *ScalarFunction) MarshalJSON() ([]byte, error) {

// NewFunction creates a new scalar function or constant.
func NewFunction(ctx sessionctx.Context, funcName string, retType *types.FieldType, args ...Expression) (Expression, error) {
return newFunction(ctx, true, funcName, retType, args...)
}

// NewFunctionBase creates a new scalar function or constant without constant fold
func NewFunctionBase(ctx sessionctx.Context, funcName string, retType *types.FieldType, args ...Expression) (Expression, error) {
return newFunction(ctx, false, funcName, retType, args...)
}

func newFunction(ctx sessionctx.Context, fold bool, funcName string, retType *types.FieldType, args ...Expression) (Expression, error) {
if retType == nil {
return nil, errors.Errorf("RetType cannot be nil for ScalarFunction.")
}
Expand All @@ -96,7 +105,10 @@ func NewFunction(ctx sessionctx.Context, funcName string, retType *types.FieldTy
RetType: retType,
Function: f,
}
return FoldConstant(sf), nil
if fold {
return FoldConstant(sf), nil
}
return sf, nil
}

// NewFunctionInternal is similar to NewFunction, but do not returns error, should only be used internally.
Expand Down

0 comments on commit 55d7433

Please sign in to comment.