Skip to content

Commit

Permalink
use builtinJSONMergeSig
Browse files Browse the repository at this point in the history
  • Loading branch information
shinytang6 committed Jan 8, 2019
1 parent d2521c5 commit b13e432
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions expression/builtin_json.go
Expand Up @@ -722,16 +722,6 @@ type jsonMergePreserveFunctionClass struct {
baseFunctionClass
}

type builtinJSONMergePreserveSig struct {
baseBuiltinFunc
}

func (b *builtinJSONMergePreserveSig) Clone() builtinFunc {
newSig := &builtinJSONMergePreserveSig{}
newSig.cloneFrom(&b.baseBuiltinFunc)
return newSig
}

func (c *jsonMergePreserveFunctionClass) getFunction(ctx sessionctx.Context, args []Expression) (builtinFunc, error) {
if err := c.verifyArgs(args); err != nil {
return nil, err
Expand All @@ -741,25 +731,11 @@ func (c *jsonMergePreserveFunctionClass) getFunction(ctx sessionctx.Context, arg
argTps = append(argTps, types.ETJson)
}
bf := newBaseBuiltinFuncWithTp(ctx, args, types.ETJson, argTps...)
sig := &builtinJSONMergePreserveSig{bf}
sig := &builtinJSONMergeSig{bf}
sig.setPbCode(tipb.ScalarFuncSig_JsonMergePreserveSig)
return sig, nil
}

func (b *builtinJSONMergePreserveSig) evalJSON(row chunk.Row) (res json.BinaryJSON, isNull bool, err error) {
values := make([]json.BinaryJSON, 0, len(b.args))
for _, arg := range b.args {
var value json.BinaryJSON
value, isNull, err = arg.EvalJSON(b.ctx, row)
if isNull || err != nil {
return res, isNull, err
}
values = append(values, value)
}
res = json.MergeBinary(values)
return res, false, nil
}

type jsonPrettyFunctionClass struct {
baseFunctionClass
}
Expand Down

0 comments on commit b13e432

Please sign in to comment.