MCPcopy Create free account
hub / github.com/pingcap/tidb / getFunction

Method getFunction

pkg/expression/builtin_cast.go:623–645  ·  view source on GitHub ↗
(ctx BuildContext, args []Expression)

Source from the content-addressed store, hash-verified

621}
622
623func (c *castAsArrayFunctionClass) getFunction(ctx BuildContext, args []Expression) (sig builtinFunc, err error) {
624 if err := c.verifyArgs(ctx.GetEvalCtx(), args); err != nil {
625 return nil, err
626 }
627 arrayType := c.tp.ArrayType()
628 switch arrayType.GetType() {
629 case mysql.TypeYear, mysql.TypeJSON, mysql.TypeFloat, mysql.TypeNewDecimal:
630 return nil, ErrNotSupportedYet.GenWithStackByArgs(fmt.Sprintf("CAST-ing data to array of %s", arrayType.String()))
631 }
632 if arrayType.EvalType() == types.ETString && arrayType.GetCharset() != charset.CharsetUTF8MB4 && arrayType.GetCharset() != charset.CharsetBin {
633 return nil, ErrNotSupportedYet.GenWithStackByArgs("specifying charset for multi-valued index")
634 }
635 if arrayType.EvalType() == types.ETString && arrayType.GetFlen() == types.UnspecifiedLength {
636 return nil, ErrNotSupportedYet.GenWithStackByArgs("CAST-ing data to array of char/binary BLOBs with unspecified length")
637 }
638
639 bf, err := newBaseBuiltinFunc(ctx, c.funcName, args, c.tp)
640 if err != nil {
641 return nil, err
642 }
643 sig = &castJSONAsArrayFunctionSig{bf}
644 return sig, nil
645}
646
647type castJSONAsArrayFunctionSig struct {
648 baseBuiltinFunc

Callers

nothing calls this directly

Calls 9

verifyArgsMethod · 0.95
newBaseBuiltinFuncFunction · 0.85
ArrayTypeMethod · 0.80
EvalTypeMethod · 0.80
GetEvalCtxMethod · 0.65
GetTypeMethod · 0.65
StringMethod · 0.65
GetCharsetMethod · 0.45
GetFlenMethod · 0.45

Tested by

no test coverage detected