Skip to content

Commit 24a4514

Browse files
author
Thomas Charlot
committed
go module
1 parent 6947967 commit 24a4514

11 files changed

Lines changed: 96 additions & 138 deletions

File tree

Gopkg.lock

Lines changed: 0 additions & 53 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

eval.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ func (n binaryNode) Eval(env interface{}) (interface{}, error) {
139139
return multiply.Call(left, right), nil
140140

141141
case "/":
142-
if div, ok := cast.AsFloat(right); ok && div == 0 {
142+
if div, ok := cast.AsFloat64(right); ok && div == 0 {
143143
return nil, fmt.Errorf("division by zero")
144144
}
145145
return divide.Call(left, right), nil
146146

147147
case "%":
148-
if div, ok := cast.AsInt(right); ok && div == 0 {
148+
if div, ok := cast.AsInt64(right); ok && div == 0 {
149149
return nil, fmt.Errorf("division by zero")
150150
}
151151
return remainder.Call(left, right), nil

func_agg.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
// AVG(x...)
99
// Returns the average of all values of X
1010
var avg = func(x ...interface{}) interface{} {
11-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
11+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
1212
if s, err := stats.Mean(values); err == nil {
1313
return s
1414
}
@@ -38,7 +38,7 @@ var countdistinct = func(x ...interface{}) interface{} {
3838
// CUSUM(x...)
3939
// Returns the cumulative sum of values of X
4040
var cusum = func(x ...interface{}) interface{} {
41-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
41+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
4242
if s, err := stats.CumulativeSum(values); err == nil {
4343
return s
4444
}
@@ -49,7 +49,7 @@ var cusum = func(x ...interface{}) interface{} {
4949
// MAX(x...)
5050
// Returns the maximum value of X
5151
var max = func(x ...interface{}) interface{} {
52-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
52+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
5353
if s, err := stats.Max(values); err == nil {
5454
return s
5555
}
@@ -60,7 +60,7 @@ var max = func(x ...interface{}) interface{} {
6060
// MEDIAN(x...)
6161
// Returns the median of all values of X
6262
var median = func(x ...interface{}) interface{} {
63-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
63+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
6464
if s, err := stats.Median(values); err == nil {
6565
return s
6666
}
@@ -71,7 +71,7 @@ var median = func(x ...interface{}) interface{} {
7171
// MIN(x...)
7272
// Returns the minimum value of X
7373
var min = func(x ...interface{}) interface{} {
74-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
74+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
7575
if s, err := stats.Min(values); err == nil {
7676
return s
7777
}
@@ -82,8 +82,8 @@ var min = func(x ...interface{}) interface{} {
8282
// PERCENTILE(r, x...)
8383
// Returns the percentile rank R of X
8484
var percentile = func(r interface{}, x ...interface{}) interface{} {
85-
if rank, rok := cast.AsFloat(r); rok {
86-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
85+
if rank, rok := cast.AsFloat64(r); rok {
86+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
8787
if s, err := stats.Percentile(values, rank); err == nil {
8888
return s
8989
}
@@ -95,7 +95,7 @@ var percentile = func(r interface{}, x ...interface{}) interface{} {
9595
// STDDEV(x...)
9696
// Returns the standard deviation of X
9797
var stddev = func(x ...interface{}) interface{} {
98-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
98+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
9999
if s, err := stats.StandardDeviation(values); err == nil {
100100
return s
101101
}
@@ -106,7 +106,7 @@ var stddev = func(x ...interface{}) interface{} {
106106
// SUM(x...)
107107
// Returns the sum of all values of X
108108
var sum = func(x ...interface{}) interface{} {
109-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
109+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
110110
if s, err := stats.Sum(values); err == nil {
111111
return s
112112
}
@@ -117,7 +117,7 @@ var sum = func(x ...interface{}) interface{} {
117117
// VARIANCE(x...)
118118
// Returns the variance of X
119119
var variance = func(x ...interface{}) interface{} {
120-
if values, ok := cast.AsFloatArray(flatten(x)...); ok {
120+
if values, ok := cast.AsFloat64Slice(flatten(x)...); ok {
121121
if s, err := stats.Variance(values); err == nil {
122122
return s
123123
}

func_date.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
// DATE_DIFF(x date, y date)
88
// Returns the difference in days between X and Y (X - Y)
99
var dateDiff binaryOperatorFunc = func(x interface{}, y interface{}) interface{} {
10-
cx, okx := cast.AsDatetime(x)
11-
cy, oky := cast.AsDatetime(y)
10+
cx, okx := cast.AsTime(x)
11+
cy, oky := cast.AsTime(y)
1212
if !okx || !oky {
1313
return nil
1414
}
@@ -18,7 +18,7 @@ var dateDiff binaryOperatorFunc = func(x interface{}, y interface{}) interface{}
1818
// DAY(x date)
1919
// Returns the day of X
2020
var day unaryOperatorFunc = func(x interface{}) interface{} {
21-
cx, okx := cast.AsDatetime(x)
21+
cx, okx := cast.AsTime(x)
2222
if !okx {
2323
return nil
2424
}
@@ -28,7 +28,7 @@ var day unaryOperatorFunc = func(x interface{}) interface{} {
2828
// HOUR(x date)
2929
// Returns the hours in X in UTC timezone
3030
var hour unaryOperatorFunc = func(x interface{}) interface{} {
31-
cx, okx := cast.AsDatetime(x)
31+
cx, okx := cast.AsTime(x)
3232
if !okx {
3333
return nil
3434
}
@@ -38,7 +38,7 @@ var hour unaryOperatorFunc = func(x interface{}) interface{} {
3838
// MINUTE(x date)
3939
// Returns the minutes in X in UTC timezone
4040
var minute unaryOperatorFunc = func(x interface{}) interface{} {
41-
cx, okx := cast.AsDatetime(x)
41+
cx, okx := cast.AsTime(x)
4242
if !okx {
4343
return nil
4444
}
@@ -48,7 +48,7 @@ var minute unaryOperatorFunc = func(x interface{}) interface{} {
4848
// MONTH(x date)
4949
// Returns the month in X
5050
var month unaryOperatorFunc = func(x interface{}) interface{} {
51-
cx, okx := cast.AsDatetime(x)
51+
cx, okx := cast.AsTime(x)
5252
if !okx {
5353
return nil
5454
}
@@ -58,7 +58,7 @@ var month unaryOperatorFunc = func(x interface{}) interface{} {
5858
// QUARTER(x date)
5959
// Returns the quarter of X
6060
var quarter unaryOperatorFunc = func(x interface{}) interface{} {
61-
cx, okx := cast.AsDatetime(x)
61+
cx, okx := cast.AsTime(x)
6262
if !okx {
6363
return nil
6464
}
@@ -68,7 +68,7 @@ var quarter unaryOperatorFunc = func(x interface{}) interface{} {
6868
// SECOND(x date)
6969
// Returns the seconds in X in UTC timezone
7070
var second unaryOperatorFunc = func(x interface{}) interface{} {
71-
cx, okx := cast.AsDatetime(x)
71+
cx, okx := cast.AsTime(x)
7272
if !okx {
7373
return nil
7474
}
@@ -78,7 +78,7 @@ var second unaryOperatorFunc = func(x interface{}) interface{} {
7878
// WEEK(x date)
7979
// Returns the week of X from start of year as per ISO 8601 standard
8080
var week unaryOperatorFunc = func(x interface{}) interface{} {
81-
cx, okx := cast.AsDatetime(x)
81+
cx, okx := cast.AsTime(x)
8282
if !okx {
8383
return nil
8484
}
@@ -89,7 +89,7 @@ var week unaryOperatorFunc = func(x interface{}) interface{} {
8989
// WEEKDAY(x date)
9090
// Returns the day of the week of X
9191
var weekday unaryOperatorFunc = func(x interface{}) interface{} {
92-
cx, okx := cast.AsDatetime(x)
92+
cx, okx := cast.AsTime(x)
9393
if !okx {
9494
return nil
9595
}
@@ -99,7 +99,7 @@ var weekday unaryOperatorFunc = func(x interface{}) interface{} {
9999
// YEAR(x date)
100100
// Returns the year of X
101101
var year unaryOperatorFunc = func(x interface{}) interface{} {
102-
cx, okx := cast.AsDatetime(x)
102+
cx, okx := cast.AsTime(x)
103103
if !okx {
104104
return nil
105105
}

func_math.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,71 @@ import (
88

99
// ABS(x float)
1010
var abs unaryOperatorFunc = func(x interface{}) interface{} {
11-
if cx, okx := cast.AsFloat(x); okx {
11+
if cx, okx := cast.AsFloat64(x); okx {
1212
return math.Abs(cx)
1313
}
1414
return nil
1515
}
1616

1717
// ACOS(x float)
1818
var acos unaryOperatorFunc = func(x interface{}) interface{} {
19-
if cx, okx := cast.AsFloat(x); okx {
19+
if cx, okx := cast.AsFloat64(x); okx {
2020
return math.Acos(cx)
2121
}
2222
return nil
2323
}
2424

2525
// ASIN(x float)
2626
var asin unaryOperatorFunc = func(x interface{}) interface{} {
27-
if cx, okx := cast.AsFloat(x); okx {
27+
if cx, okx := cast.AsFloat64(x); okx {
2828
return math.Asin(cx)
2929
}
3030
return nil
3131
}
3232

3333
// ATAN(x float)
3434
var atan unaryOperatorFunc = func(x interface{}) interface{} {
35-
if cx, okx := cast.AsFloat(x); okx {
35+
if cx, okx := cast.AsFloat64(x); okx {
3636
return math.Atan(cx)
3737
}
3838
return nil
3939
}
4040

4141
// CEIL(x float)
4242
var ceil unaryOperatorFunc = func(x interface{}) interface{} {
43-
if cx, okx := cast.AsFloat(x); okx {
43+
if cx, okx := cast.AsFloat64(x); okx {
4444
return math.Ceil(cx)
4545
}
4646
return nil
4747
}
4848

4949
// COS(x float)
5050
var cos unaryOperatorFunc = func(x interface{}) interface{} {
51-
if cx, okx := cast.AsFloat(x); okx {
51+
if cx, okx := cast.AsFloat64(x); okx {
5252
return math.Cos(cx)
5353
}
5454
return nil
5555
}
5656

5757
// FLOOR(x float)
5858
var floor unaryOperatorFunc = func(x interface{}) interface{} {
59-
if cx, okx := cast.AsFloat(x); okx {
59+
if cx, okx := cast.AsFloat64(x); okx {
6060
return math.Floor(cx)
6161
}
6262
return nil
6363
}
6464

6565
// LOG(x float)
6666
var log unaryOperatorFunc = func(x interface{}) interface{} {
67-
if cx, okx := cast.AsFloat(x); okx {
67+
if cx, okx := cast.AsFloat64(x); okx {
6868
return math.Log(cx)
6969
}
7070
return nil
7171
}
7272

7373
// LOG10(x float)
7474
var log10 unaryOperatorFunc = func(x interface{}) interface{} {
75-
if cx, okx := cast.AsFloat(x); okx {
75+
if cx, okx := cast.AsFloat64(x); okx {
7676
return math.Log10(cx)
7777
}
7878
return nil
@@ -81,8 +81,8 @@ var log10 unaryOperatorFunc = func(x interface{}) interface{} {
8181
// POW(x float, y float)
8282
// Used with operator **
8383
var pow binaryOperatorFunc = func(x, y interface{}) interface{} {
84-
cx, okx := cast.AsFloat(x)
85-
cy, oky := cast.AsFloat(y)
84+
cx, okx := cast.AsFloat64(x)
85+
cy, oky := cast.AsFloat64(y)
8686
if !okx || !oky {
8787
return nil
8888
}
@@ -91,23 +91,23 @@ var pow binaryOperatorFunc = func(x, y interface{}) interface{} {
9191

9292
// ROUND(x float)
9393
var round unaryOperatorFunc = func(x interface{}) interface{} {
94-
if cx, okx := cast.AsFloat(x); okx {
94+
if cx, okx := cast.AsFloat64(x); okx {
9595
return math.Round(cx)
9696
}
9797
return nil
9898
}
9999

100100
// SIN(x float)
101101
var sin unaryOperatorFunc = func(x interface{}) interface{} {
102-
if cx, okx := cast.AsFloat(x); okx {
102+
if cx, okx := cast.AsFloat64(x); okx {
103103
return math.Sin(cx)
104104
}
105105
return nil
106106
}
107107

108108
// TAN(x float)
109109
var tan unaryOperatorFunc = func(x interface{}) interface{} {
110-
if cx, okx := cast.AsFloat(x); okx {
110+
if cx, okx := cast.AsFloat64(x); okx {
111111
return math.Tan(cx)
112112
}
113113
return nil

0 commit comments

Comments
 (0)