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

Method Call

runtime/sam/expr/function/datepart.go:16–28  ·  view source on GitHub ↗
(args []super.Value)

Source from the content-addressed store, hash-verified

14}
15
16func (d *DatePart) Call(args []super.Value) super.Value {
17 if args[0].Type().ID() != super.IDString {
18 return d.sctx.WrapError("date_part: string value required for part argument", args[0])
19 }
20 if args[1].Type().ID() != super.IDTime {
21 return d.sctx.WrapError("date_part: time value required for time argument", args[1])
22 }
23 fn := lookupDatePartEval(args[0].AsString())
24 if fn == nil {
25 return d.sctx.WrapError("date_part: unsupported part name", args[0])
26 }
27 return super.NewInt64(fn(args[1].AsTime()))
28}
29
30func lookupDatePartEval(part string) func(nano.Ts) int64 {
31 switch part {

Callers

nothing calls this directly

Calls 7

NewInt64Function · 0.92
lookupDatePartEvalFunction · 0.85
WrapErrorMethod · 0.80
AsStringMethod · 0.80
AsTimeMethod · 0.80
IDMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected