@@ -33,7 +33,11 @@ let typeOfScalarFunction fn args =
33
33
| Length -> IntegerType
34
34
| Round
35
35
| Floor
36
- | Ceil -> IntegerType
36
+ | Ceil ->
37
+ match args with
38
+ | [ _ ] -> IntegerType
39
+ | [ _; amount ] -> typeOf amount
40
+ | _ -> failwith $" Invalid arguments supplied to function `#{fn}`."
37
41
| Abs -> args |> List.exactlyOne |> typeOf
38
42
| Lower
39
43
| Upper
@@ -104,6 +108,38 @@ let rec evaluateScalarFunction fn args =
104
108
| And, [ Boolean b1; Boolean b2 ] -> Boolean( b1 && b2)
105
109
| Or, [ Boolean b1; Boolean b2 ] -> Boolean( b1 || b2)
106
110
111
+ | Round, [ Real r ] -> r |> round |> int64 |> Integer
112
+ | Round, [ _; Integer amount ] when amount <= 0 L -> Null
113
+ | Round, [ _; Real amount ] when amount <= 0.0 -> Null
114
+ | Round, [ Integer value; Integer amount ] -> ( float value / float amount) |> round |> int64 |> (*) amount |> Integer
115
+ | Round, [ Integer value; Real amount ] -> ( float value / amount) |> round |> (*) amount |> Real
116
+ | Round, [ Real value; Integer amount ] -> ( value / float amount) |> round |> int64 |> (*) amount |> Integer
117
+ | Round, [ Real value; Real amount ] -> ( value / amount) |> round |> (*) amount |> Real
118
+
119
+ | Ceil, [ Real r ] -> r |> ceil |> int64 |> Integer
120
+ | Ceil, [ _; Integer amount ] when amount <= 0 L -> Null
121
+ | Ceil, [ _; Real amount ] when amount <= 0.0 -> Null
122
+ | Ceil, [ Integer value; Integer amount ] -> ( float value / float amount) |> ceil |> int64 |> (*) amount |> Integer
123
+ | Ceil, [ Integer value; Real amount ] -> ( float value / amount) |> ceil |> (*) amount |> Real
124
+ | Ceil, [ Real value; Integer amount ] -> ( value / float amount) |> ceil |> int64 |> (*) amount |> Integer
125
+ | Ceil, [ Real value; Real amount ] -> ( value / amount) |> ceil |> (*) amount |> Real
126
+
127
+ | Floor, [ Real r ] -> r |> floor |> int64 |> Integer
128
+ | Floor, [ _; Integer amount ] when amount <= 0 L -> Null
129
+ | Floor, [ _; Real amount ] when amount <= 0.0 -> Null
130
+ | Floor, [ Integer value; Integer amount ] -> ( float value / float amount) |> floor |> int64 |> (*) amount |> Integer
131
+ | Floor, [ Integer value; Real amount ] -> ( float value / amount) |> floor |> (*) amount |> Real
132
+ | Floor, [ Real value; Integer amount ] -> ( value / float amount) |> floor |> int64 |> (*) amount |> Integer
133
+ | Floor, [ Real value; Real amount ] -> ( value / amount) |> floor |> (*) amount |> Real
134
+
135
+ | Abs, [ Real r ] -> r |> abs |> Real
136
+ | Abs, [ Integer i ] -> i |> abs |> Integer
137
+
138
+ | WidthBucket, [ Integer v; Integer b; Integer t; Integer c ] ->
139
+ widthBucket ( float v) ( float b) ( float t) c |> Integer
140
+ | WidthBucket, [ Real v; Real b; Real t; Integer c ] -> widthBucket v b t c |> Integer
141
+
142
+ // Treat mixed integer/real binary operations as real/real operations.
107
143
| _, [ Integer i; Real r ] -> evaluateScalarFunction fn [ Real( double i); Real r ]
108
144
| _, [ Real r; Integer i ] -> evaluateScalarFunction fn [ Real r; Real( double i) ]
109
145
@@ -124,16 +160,6 @@ let rec evaluateScalarFunction fn args =
124
160
| Gt, [ v1; v2 ] -> Boolean( v1 > v2)
125
161
| GtE, [ v1; v2 ] -> Boolean( v1 >= v2)
126
162
127
- | Round, [ Real r ] -> r |> round |> int64 |> Integer
128
- | Ceil, [ Real r ] -> r |> ceil |> int64 |> Integer
129
- | Floor, [ Real r ] -> r |> floor |> int64 |> Integer
130
- | Abs, [ Real r ] -> r |> abs |> Real
131
- | Abs, [ Integer i ] -> i |> abs |> Integer
132
-
133
- | WidthBucket, [ Integer v; Integer b; Integer t; Integer c ] ->
134
- widthBucket ( float v) ( float b) ( float t) c |> Integer
135
- | WidthBucket, [ Real v; Real b; Real t; Integer c ] -> widthBucket v b t c |> Integer
136
-
137
163
| Length, [ String s ] -> Integer( int64 s.Length)
138
164
139
165
| Lower, [ String s ] -> String( s.ToLower())
0 commit comments