MCPcopy Create free account
hub / github.com/brimdata/super / Call

Method Call

runtime/vam/expr/function/datepart.go:16–32  ·  view source on GitHub ↗
(args ...vector.Any)

Source from the content-addressed store, hash-verified

14}
15
16func (d *DatePart) Call(args ...vector.Any) vector.Any {
17 if args[0].Type().ID() != super.IDString {
18 return vector.NewWrappedError(d.sctx, "date_part: string value required for part argument", args[0])
19 }
20 if args[1].Type().ID() != super.IDTime {
21 return vector.NewWrappedError(d.sctx, "date_part: time value required for time argument", args[1])
22 }
23 partArg, timeArg := vector.Under(args[0]), vector.Under(args[1])
24 if _, ok := partArg.(*vector.Const); !ok {
25 return d.slow(partArg, timeArg)
26 }
27 fn := datePartFuncs[vector.StringValue(partArg, 0)]
28 if fn == nil {
29 return vector.NewWrappedError(d.sctx, "date_part: unknown part name", args[0])
30 }
31 return fn(timeArg)
32}
33
34func (d *DatePart) slow(partArg, timeArg vector.Any) vector.Any {
35 fn := samfunc.NewDatePart(d.sctx)

Callers 1

slowMethod · 0.95

Calls 6

slowMethod · 0.95
NewWrappedErrorFunction · 0.92
UnderFunction · 0.92
StringValueFunction · 0.92
IDMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected