func (a *stddevAggregate) Result() (Datum, error) { variance, err := a.varianceAggregate.Result() if err != nil || variance == DNull { return variance, err } switch t := variance.(type) { case *DFloat: return NewDFloat(DFloat(math.Sqrt(float64(*t)))), nil case *DDecimal: decimal.Sqrt(&t.Dec, &t.Dec, decimal.Precision) return t, nil } return nil, util.Errorf("unexpected variance result type: %s", variance.Type()) }
}, }, "sqrt": { floatBuiltin1(func(x float64) (Datum, error) { if x < 0 { return nil, errSqrtOfNegNumber } return DFloat(math.Sqrt(x)), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { if x.Sign() < 0 { return nil, errSqrtOfNegNumber } dd := &DDecimal{} decimal.Sqrt(&dd.Dec, x, decimal.Precision) return dd, nil }), }, "tan": { floatBuiltin1(func(x float64) (Datum, error) { return DFloat(math.Tan(x)), nil }), }, "trunc": { floatBuiltin1(func(x float64) (Datum, error) { return DFloat(math.Trunc(x)), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) {