@@ -7,6 +7,14 @@ import org.partiql.spi.function.PartiQLFunction
7
7
import org.partiql.spi.function.PartiQLFunctionExperimental
8
8
import org.partiql.types.function.FunctionParameter
9
9
import org.partiql.types.function.FunctionSignature
10
+ import org.partiql.value.DecimalValue
11
+ import org.partiql.value.Float32Value
12
+ import org.partiql.value.Float64Value
13
+ import org.partiql.value.Int16Value
14
+ import org.partiql.value.Int32Value
15
+ import org.partiql.value.Int64Value
16
+ import org.partiql.value.Int8Value
17
+ import org.partiql.value.IntValue
10
18
import org.partiql.value.PartiQLValue
11
19
import org.partiql.value.PartiQLValueExperimental
12
20
import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY
@@ -17,6 +25,15 @@ import org.partiql.value.PartiQLValueType.INT16
17
25
import org.partiql.value.PartiQLValueType.INT32
18
26
import org.partiql.value.PartiQLValueType.INT64
19
27
import org.partiql.value.PartiQLValueType.INT8
28
+ import org.partiql.value.check
29
+ import org.partiql.value.decimalValue
30
+ import org.partiql.value.float32Value
31
+ import org.partiql.value.float64Value
32
+ import org.partiql.value.int16Value
33
+ import org.partiql.value.int32Value
34
+ import org.partiql.value.int64Value
35
+ import org.partiql.value.int8Value
36
+ import org.partiql.value.intValue
20
37
21
38
@OptIn(PartiQLValueExperimental ::class , PartiQLFunctionExperimental ::class )
22
39
internal object Fn_DIVIDE__INT8_INT8__INT8 : PartiQLFunction.Scalar {
@@ -32,8 +49,10 @@ internal object Fn_DIVIDE__INT8_INT8__INT8 : PartiQLFunction.Scalar {
32
49
isNullable = false ,
33
50
)
34
51
35
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
36
- TODO (" Function divide not implemented" )
52
+ override fun invoke (args : Array <PartiQLValue >): Int8Value {
53
+ val arg0 = args[0 ].check<Int8Value >().value!!
54
+ val arg1 = args[1 ].check<Int8Value >().value!!
55
+ return int8Value((arg0 / arg1).toByte())
37
56
}
38
57
}
39
58
@@ -51,8 +70,10 @@ internal object Fn_DIVIDE__INT16_INT16__INT16 : PartiQLFunction.Scalar {
51
70
isNullable = false ,
52
71
)
53
72
54
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
55
- TODO (" Function divide not implemented" )
73
+ override fun invoke (args : Array <PartiQLValue >): Int16Value {
74
+ val arg0 = args[0 ].check<Int16Value >().value!!
75
+ val arg1 = args[1 ].check<Int16Value >().value!!
76
+ return int16Value((arg0 / arg1).toShort())
56
77
}
57
78
}
58
79
@@ -70,8 +91,10 @@ internal object Fn_DIVIDE__INT32_INT32__INT32 : PartiQLFunction.Scalar {
70
91
isNullable = false ,
71
92
)
72
93
73
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
74
- TODO (" Function divide not implemented" )
94
+ override fun invoke (args : Array <PartiQLValue >): Int32Value {
95
+ val arg0 = args[0 ].check<Int32Value >().value!!
96
+ val arg1 = args[1 ].check<Int32Value >().value!!
97
+ return int32Value(arg0 / arg1)
75
98
}
76
99
}
77
100
@@ -89,8 +112,10 @@ internal object Fn_DIVIDE__INT64_INT64__INT64 : PartiQLFunction.Scalar {
89
112
isNullable = false ,
90
113
)
91
114
92
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
93
- TODO (" Function divide not implemented" )
115
+ override fun invoke (args : Array <PartiQLValue >): Int64Value {
116
+ val arg0 = args[0 ].check<Int64Value >().value!!
117
+ val arg1 = args[1 ].check<Int64Value >().value!!
118
+ return int64Value(arg0 / arg1)
94
119
}
95
120
}
96
121
@@ -108,8 +133,10 @@ internal object Fn_DIVIDE__INT_INT__INT : PartiQLFunction.Scalar {
108
133
isNullable = false ,
109
134
)
110
135
111
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
112
- TODO (" Function divide not implemented" )
136
+ override fun invoke (args : Array <PartiQLValue >): IntValue {
137
+ val arg0 = args[0 ].check<IntValue >().value!!
138
+ val arg1 = args[1 ].check<IntValue >().value!!
139
+ return intValue(arg0 / arg1)
113
140
}
114
141
}
115
142
@@ -127,8 +154,10 @@ internal object Fn_DIVIDE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRAR
127
154
isNullable = false ,
128
155
)
129
156
130
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
131
- TODO (" Function divide not implemented" )
157
+ override fun invoke (args : Array <PartiQLValue >): DecimalValue {
158
+ val arg0 = args[0 ].check<DecimalValue >().value!!
159
+ val arg1 = args[1 ].check<DecimalValue >().value!!
160
+ return decimalValue(arg0 / arg1)
132
161
}
133
162
}
134
163
@@ -146,8 +175,10 @@ internal object Fn_DIVIDE__FLOAT32_FLOAT32__FLOAT32 : PartiQLFunction.Scalar {
146
175
isNullable = false ,
147
176
)
148
177
149
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
150
- TODO (" Function divide not implemented" )
178
+ override fun invoke (args : Array <PartiQLValue >): Float32Value {
179
+ val arg0 = args[0 ].check<Float32Value >().value!!
180
+ val arg1 = args[1 ].check<Float32Value >().value!!
181
+ return float32Value(arg0 / arg1)
151
182
}
152
183
}
153
184
@@ -165,7 +196,9 @@ internal object Fn_DIVIDE__FLOAT64_FLOAT64__FLOAT64 : PartiQLFunction.Scalar {
165
196
isNullable = false ,
166
197
)
167
198
168
- override fun invoke (args : Array <PartiQLValue >): PartiQLValue {
169
- TODO (" Function divide not implemented" )
199
+ override fun invoke (args : Array <PartiQLValue >): Float64Value {
200
+ val arg0 = args[0 ].check<Float64Value >().value!!
201
+ val arg1 = args[1 ].check<Float64Value >().value!!
202
+ return float64Value(arg0 / arg1)
170
203
}
171
204
}
0 commit comments