diff --git a/expression/builtin_json_vec.go b/expression/builtin_json_vec.go index dfdad788380dc..8b594b767590b 100644 --- a/expression/builtin_json_vec.go +++ b/expression/builtin_json_vec.go @@ -252,9 +252,31 @@ func (b *builtinJSONArrayAppendSig) vecEvalJSON(input *chunk.Chunk, result *chun } func (b *builtinJSONUnquoteSig) vectorized() bool { - return false + return true } func (b *builtinJSONUnquoteSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error { - return errors.Errorf("not implemented") + n := input.NumRows() + buf, err := b.bufAllocator.get(types.ETJson, n) + if err != nil { + return err + } + defer b.bufAllocator.put(buf) + if err := b.args[0].VecEvalJSON(b.ctx, input, buf); err != nil { + return err + } + + result.ReserveString(n) + for i := 0; i < n; i++ { + if buf.IsNull(i) { + result.AppendNull() + continue + } + res, err := buf.GetJSON(i).Unquote() + if err != nil { + return err + } + result.AppendString(res) + } + return nil } diff --git a/expression/builtin_json_vec_test.go b/expression/builtin_json_vec_test.go index 9cddca85aa8da..e9c432e253fe7 100644 --- a/expression/builtin_json_vec_test.go +++ b/expression/builtin_json_vec_test.go @@ -38,10 +38,12 @@ var vecBuiltinJSONCases = map[string][]vecExprBenchCase{ ast.JSONSearch: {}, ast.JSONReplace: {}, ast.JSONDepth: {{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETJson}}}, - ast.JSONUnquote: {}, - ast.JSONRemove: {}, - ast.JSONMerge: {}, - ast.JSONInsert: {}, + ast.JSONUnquote: { + {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&jsonStringGener{}}}, + }, + ast.JSONRemove: {}, + ast.JSONMerge: {}, + ast.JSONInsert: {}, ast.JSONQuote: { {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETJson}}, },