1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.expression.operator.arthmetic; | |
8 | ||
9 | import static org.opensearch.sql.data.type.ExprCoreType.BYTE; | |
10 | import static org.opensearch.sql.data.type.ExprCoreType.DOUBLE; | |
11 | import static org.opensearch.sql.data.type.ExprCoreType.FLOAT; | |
12 | import static org.opensearch.sql.data.type.ExprCoreType.INTEGER; | |
13 | import static org.opensearch.sql.data.type.ExprCoreType.LONG; | |
14 | import static org.opensearch.sql.data.type.ExprCoreType.SHORT; | |
15 | import static org.opensearch.sql.data.type.ExprCoreType.STRING; | |
16 | ||
17 | import com.google.common.collect.ImmutableList; | |
18 | import java.math.BigDecimal; | |
19 | import java.math.RoundingMode; | |
20 | import java.util.Arrays; | |
21 | import java.util.List; | |
22 | import java.util.Random; | |
23 | import java.util.stream.Collectors; | |
24 | import java.util.zip.CRC32; | |
25 | import lombok.experimental.UtilityClass; | |
26 | import org.apache.commons.lang3.tuple.Pair; | |
27 | import org.opensearch.sql.data.model.ExprByteValue; | |
28 | import org.opensearch.sql.data.model.ExprDoubleValue; | |
29 | import org.opensearch.sql.data.model.ExprFloatValue; | |
30 | import org.opensearch.sql.data.model.ExprIntegerValue; | |
31 | import org.opensearch.sql.data.model.ExprLongValue; | |
32 | import org.opensearch.sql.data.model.ExprNullValue; | |
33 | import org.opensearch.sql.data.model.ExprShortValue; | |
34 | import org.opensearch.sql.data.model.ExprStringValue; | |
35 | import org.opensearch.sql.data.type.ExprCoreType; | |
36 | import org.opensearch.sql.data.type.ExprType; | |
37 | import org.opensearch.sql.expression.function.BuiltinFunctionName; | |
38 | import org.opensearch.sql.expression.function.BuiltinFunctionRepository; | |
39 | import org.opensearch.sql.expression.function.DefaultFunctionResolver; | |
40 | import org.opensearch.sql.expression.function.FunctionBuilder; | |
41 | import org.opensearch.sql.expression.function.FunctionDSL; | |
42 | import org.opensearch.sql.expression.function.FunctionName; | |
43 | import org.opensearch.sql.expression.function.FunctionSignature; | |
44 | import org.opensearch.sql.expression.function.SerializableFunction; | |
45 | ||
46 | @UtilityClass | |
47 | public class MathematicalFunction { | |
48 | /** | |
49 | * Register Mathematical Functions. | |
50 | * | |
51 | * @param repository {@link BuiltinFunctionRepository}. | |
52 | */ | |
53 | public static void register(BuiltinFunctionRepository repository) { | |
54 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → KILLED |
repository.register(abs()); |
55 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(ceil()); |
56 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(ceiling()); |
57 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(conv()); |
58 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(crc32()); |
59 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(euler()); |
60 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(exp()); |
61 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(floor()); |
62 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(ln()); |
63 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(log()); |
64 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(log10()); |
65 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(log2()); |
66 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(mod()); |
67 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(pow()); |
68 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(power()); |
69 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(round()); |
70 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(sign()); |
71 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(sqrt()); |
72 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(truncate()); |
73 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(pi()); |
74 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(rand()); |
75 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(acos()); |
76 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(asin()); |
77 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(atan()); |
78 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(atan2()); |
79 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(cos()); |
80 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(cot()); |
81 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(degrees()); |
82 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(radians()); |
83 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(sin()); |
84 |
1
1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED |
repository.register(tan()); |
85 | } | |
86 | ||
87 | /** | |
88 | * Definition of abs() function. The supported signature of abs() function are INT -> INT LONG -> | |
89 | * LONG FLOAT -> FLOAT DOUBLE -> DOUBLE | |
90 | */ | |
91 | private static DefaultFunctionResolver abs() { | |
92 |
1
1. abs : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::abs → KILLED |
return FunctionDSL.define(BuiltinFunctionName.ABS.getName(), |
93 | FunctionDSL.impl( | |
94 |
1
1. lambda$abs$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$abs$12c7dc48$1 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprByteValue(Math.abs(v.byteValue()))), |
95 | BYTE, BYTE), | |
96 | FunctionDSL.impl( | |
97 |
1
1. lambda$abs$12c7dc48$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$abs$12c7dc48$2 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprShortValue(Math.abs(v.shortValue()))), |
98 | SHORT, SHORT), | |
99 | FunctionDSL.impl( | |
100 |
1
1. lambda$abs$12c7dc48$3 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$abs$12c7dc48$3 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprIntegerValue(Math.abs(v.integerValue()))), |
101 | INTEGER, INTEGER), | |
102 | FunctionDSL.impl( | |
103 |
1
1. lambda$abs$12c7dc48$4 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$abs$12c7dc48$4 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprLongValue(Math.abs(v.longValue()))), |
104 | LONG, LONG), | |
105 | FunctionDSL.impl( | |
106 |
1
1. lambda$abs$12c7dc48$5 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$abs$12c7dc48$5 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprFloatValue(Math.abs(v.floatValue()))), |
107 | FLOAT, FLOAT), | |
108 | FunctionDSL.impl( | |
109 |
1
1. lambda$abs$12c7dc48$6 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$abs$12c7dc48$6 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprDoubleValue(Math.abs(v.doubleValue()))), |
110 | DOUBLE, DOUBLE) | |
111 | ); | |
112 | } | |
113 | ||
114 | /** | |
115 | * Definition of ceil(x)/ceiling(x) function. Calculate the next highest integer that x rounds up | |
116 | * to The supported signature of ceil/ceiling function is DOUBLE -> INTEGER | |
117 | */ | |
118 | private static DefaultFunctionResolver ceil() { | |
119 |
1
1. ceil : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::ceil → KILLED |
return FunctionDSL.define(BuiltinFunctionName.CEIL.getName(), |
120 | FunctionDSL.impl( | |
121 |
1
1. lambda$ceil$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$ceil$12c7dc48$1 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprIntegerValue(Math.ceil(v.doubleValue()))), |
122 | INTEGER, DOUBLE) | |
123 | ); | |
124 | } | |
125 | ||
126 | private static DefaultFunctionResolver ceiling() { | |
127 |
1
1. ceiling : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::ceiling → KILLED |
return FunctionDSL.define(BuiltinFunctionName.CEILING.getName(), |
128 | FunctionDSL.impl( | |
129 |
1
1. lambda$ceiling$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$ceiling$12c7dc48$1 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprIntegerValue(Math.ceil(v.doubleValue()))), |
130 | INTEGER, DOUBLE) | |
131 | ); | |
132 | } | |
133 | ||
134 | /** | |
135 | * Definition of conv(x, a, b) function. | |
136 | * Convert number x from base a to base b | |
137 | * The supported signature of floor function is | |
138 | * (STRING, INTEGER, INTEGER) -> STRING | |
139 | * (INTEGER, INTEGER, INTEGER) -> STRING | |
140 | */ | |
141 | private static DefaultFunctionResolver conv() { | |
142 |
1
1. conv : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::conv → KILLED |
return FunctionDSL.define(BuiltinFunctionName.CONV.getName(), |
143 | FunctionDSL.impl( | |
144 |
1
1. lambda$conv$d3d4fc58$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$conv$d3d4fc58$1 → KILLED |
FunctionDSL.nullMissingHandling((x, a, b) -> new ExprStringValue( |
145 | Integer.toString(Integer.parseInt(x.stringValue(), a.integerValue()), | |
146 | b.integerValue()) | |
147 | )), | |
148 | STRING, STRING, INTEGER, INTEGER), | |
149 | FunctionDSL.impl( | |
150 |
1
1. lambda$conv$d3d4fc58$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$conv$d3d4fc58$2 → KILLED |
FunctionDSL.nullMissingHandling((x, a, b) -> new ExprStringValue( |
151 | Integer.toString(Integer.parseInt(x.integerValue().toString(), a.integerValue()), | |
152 | b.integerValue()) | |
153 | )), | |
154 | STRING, INTEGER, INTEGER, INTEGER) | |
155 | ); | |
156 | } | |
157 | ||
158 | /** | |
159 | * Definition of crc32(x) function. | |
160 | * Calculate a cyclic redundancy check value and returns a 32-bit unsigned value | |
161 | * The supported signature of crc32 function is | |
162 | * STRING -> LONG | |
163 | */ | |
164 | private static DefaultFunctionResolver crc32() { | |
165 |
1
1. crc32 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::crc32 → KILLED |
return FunctionDSL.define(BuiltinFunctionName.CRC32.getName(), |
166 | FunctionDSL.impl( | |
167 | FunctionDSL.nullMissingHandling(v -> { | |
168 | CRC32 crc = new CRC32(); | |
169 |
1
1. lambda$crc32$12c7dc48$1 : removed call to java/util/zip/CRC32::update → KILLED |
crc.update(v.stringValue().getBytes()); |
170 |
1
1. lambda$crc32$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$crc32$12c7dc48$1 → KILLED |
return new ExprLongValue(crc.getValue()); |
171 | }), | |
172 | LONG, STRING) | |
173 | ); | |
174 | } | |
175 | ||
176 | /** | |
177 | * Definition of e() function. | |
178 | * Get the Euler's number. | |
179 | * () -> DOUBLE | |
180 | */ | |
181 | private static DefaultFunctionResolver euler() { | |
182 |
1
1. euler : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::euler → KILLED |
return FunctionDSL.define(BuiltinFunctionName.E.getName(), |
183 |
1
1. lambda$euler$19cc14d4$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$euler$19cc14d4$1 → KILLED |
FunctionDSL.impl(() -> new ExprDoubleValue(Math.E), DOUBLE) |
184 | ); | |
185 | } | |
186 | ||
187 | /** | |
188 | * Definition of exp(x) function. Calculate exponent function e to the x The supported signature | |
189 | * of exp function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
190 | */ | |
191 | private static DefaultFunctionResolver exp() { | |
192 |
1
1. exp : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::exp → KILLED |
return FunctionDSL.define(BuiltinFunctionName.EXP.getName(), |
193 | ExprCoreType.numberTypes().stream() | |
194 |
1
1. lambda$exp$0 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$exp$0 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
195 |
1
1. lambda$exp$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$exp$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.exp(v.doubleValue()))), |
196 | type, DOUBLE)).collect(Collectors.toList())); | |
197 | } | |
198 | ||
199 | /** | |
200 | * Definition of floor(x) function. Calculate the next nearest whole integer that x rounds down to | |
201 | * The supported signature of floor function is DOUBLE -> INTEGER | |
202 | */ | |
203 | private static DefaultFunctionResolver floor() { | |
204 |
1
1. floor : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::floor → KILLED |
return FunctionDSL.define(BuiltinFunctionName.FLOOR.getName(), |
205 | FunctionDSL.impl( | |
206 |
1
1. lambda$floor$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$floor$12c7dc48$1 → KILLED |
FunctionDSL.nullMissingHandling(v -> new ExprIntegerValue(Math.floor(v.doubleValue()))), |
207 | INTEGER, DOUBLE) | |
208 | ); | |
209 | } | |
210 | ||
211 | /** | |
212 | * Definition of ln(x) function. Calculate the natural logarithm of x The supported signature of | |
213 | * ln function is INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
214 | */ | |
215 | private static DefaultFunctionResolver ln() { | |
216 |
1
1. ln : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::ln → KILLED |
return FunctionDSL.define(BuiltinFunctionName.LN.getName(), |
217 | ExprCoreType.numberTypes().stream() | |
218 |
1
1. lambda$ln$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$ln$1 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
219 |
1
1. lambda$ln$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$ln$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.log(v.doubleValue()))), |
220 | type, DOUBLE)).collect(Collectors.toList())); | |
221 | } | |
222 | ||
223 | /** | |
224 | * Definition of log(b, x) function. Calculate the logarithm of x using b as the base The | |
225 | * supported signature of log function is (b: INTEGER/LONG/FLOAT/DOUBLE, x: | |
226 | * INTEGER/LONG/FLOAT/DOUBLE]) -> DOUBLE | |
227 | */ | |
228 | private static DefaultFunctionResolver log() { | |
229 | ImmutableList.Builder<SerializableFunction<FunctionName, Pair<FunctionSignature, | |
230 | FunctionBuilder>>> builder = new ImmutableList.Builder<>(); | |
231 | ||
232 | // build unary log(x), SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
233 | for (ExprType type : ExprCoreType.numberTypes()) { | |
234 | builder.add(FunctionDSL.impl(FunctionDSL | |
235 |
1
1. lambda$log$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$log$12c7dc48$1 → KILLED |
.nullMissingHandling(v -> new ExprDoubleValue(Math.log(v.doubleValue()))), |
236 | DOUBLE, type)); | |
237 | } | |
238 | ||
239 | // build binary function log(b, x) | |
240 | for (ExprType baseType : ExprCoreType.numberTypes()) { | |
241 | for (ExprType numberType : ExprCoreType.numberTypes()) { | |
242 | builder.add(FunctionDSL.impl(FunctionDSL | |
243 |
1
1. lambda$log$95048fc1$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$log$95048fc1$1 → KILLED |
.nullMissingHandling((b, x) -> new ExprDoubleValue( |
244 |
1
1. lambda$log$95048fc1$1 : Replaced double division with multiplication → KILLED |
Math.log(x.doubleValue()) / Math.log(b.doubleValue()))), |
245 | DOUBLE, baseType, numberType)); | |
246 | } | |
247 | } | |
248 |
1
1. log : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::log → KILLED |
return FunctionDSL.define(BuiltinFunctionName.LOG.getName(), builder.build()); |
249 | } | |
250 | ||
251 | ||
252 | /** | |
253 | * Definition of log10(x) function. Calculate base-10 logarithm of x The supported signature of | |
254 | * log function is SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
255 | */ | |
256 | private static DefaultFunctionResolver log10() { | |
257 |
1
1. log10 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::log10 → KILLED |
return FunctionDSL.define(BuiltinFunctionName.LOG10.getName(), |
258 | ExprCoreType.numberTypes().stream() | |
259 |
1
1. lambda$log10$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$log10$2 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
260 |
1
1. lambda$log10$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$log10$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.log10(v.doubleValue()))), |
261 | type, DOUBLE)).collect(Collectors.toList())); | |
262 | } | |
263 | ||
264 | /** | |
265 | * Definition of log2(x) function. Calculate base-2 logarithm of x The supported signature of log | |
266 | * function is SHORT/INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
267 | */ | |
268 | private static DefaultFunctionResolver log2() { | |
269 |
1
1. log2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::log2 → KILLED |
return FunctionDSL.define(BuiltinFunctionName.LOG2.getName(), |
270 | ExprCoreType.numberTypes().stream() | |
271 |
1
1. lambda$log2$3 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$log2$3 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
272 |
2
1. lambda$log2$12c7dc48$1 : Replaced double division with multiplication → KILLED 2. lambda$log2$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$log2$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.log(v.doubleValue()) / Math.log(2))), DOUBLE, type)) |
273 | .collect(Collectors.toList())); | |
274 | } | |
275 | ||
276 | /** | |
277 | * Definition of mod(x, y) function. | |
278 | * Calculate the remainder of x divided by y | |
279 | * The supported signature of mod function is | |
280 | * (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) | |
281 | * -> wider type between types of x and y | |
282 | */ | |
283 | private static DefaultFunctionResolver mod() { | |
284 |
1
1. mod : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::mod → KILLED |
return FunctionDSL.define(BuiltinFunctionName.MOD.getName(), |
285 | FunctionDSL.impl( | |
286 | FunctionDSL.nullMissingHandling( | |
287 |
2
1. lambda$mod$95048fc1$1 : negated conditional → KILLED 2. lambda$mod$95048fc1$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$mod$95048fc1$1 → KILLED |
(v1, v2) -> v2.byteValue() == 0 ? ExprNullValue.of() : |
288 |
1
1. lambda$mod$95048fc1$1 : Replaced integer modulus with multiplication → KILLED |
new ExprByteValue(v1.byteValue() % v2.byteValue())), |
289 | BYTE, BYTE, BYTE), | |
290 | FunctionDSL.impl( | |
291 | FunctionDSL.nullMissingHandling( | |
292 |
2
1. lambda$mod$95048fc1$2 : negated conditional → KILLED 2. lambda$mod$95048fc1$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$mod$95048fc1$2 → KILLED |
(v1, v2) -> v2.shortValue() == 0 ? ExprNullValue.of() : |
293 |
1
1. lambda$mod$95048fc1$2 : Replaced integer modulus with multiplication → KILLED |
new ExprShortValue(v1.shortValue() % v2.shortValue())), |
294 | SHORT, SHORT, SHORT), | |
295 | FunctionDSL.impl( | |
296 | FunctionDSL.nullMissingHandling( | |
297 |
2
1. lambda$mod$95048fc1$3 : negated conditional → KILLED 2. lambda$mod$95048fc1$3 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$mod$95048fc1$3 → KILLED |
(v1, v2) -> v2.shortValue() == 0 ? ExprNullValue.of() : |
298 | new ExprIntegerValue(Math.floorMod(v1.integerValue(), | |
299 | v2.integerValue()))), | |
300 | INTEGER, INTEGER, INTEGER), | |
301 | FunctionDSL.impl( | |
302 | FunctionDSL.nullMissingHandling( | |
303 |
2
1. lambda$mod$95048fc1$4 : negated conditional → KILLED 2. lambda$mod$95048fc1$4 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$mod$95048fc1$4 → KILLED |
(v1, v2) -> v2.shortValue() == 0 ? ExprNullValue.of() : |
304 | new ExprLongValue(Math.floorMod(v1.longValue(), v2.longValue()))), | |
305 | LONG, LONG, LONG), | |
306 | FunctionDSL.impl( | |
307 | FunctionDSL.nullMissingHandling( | |
308 |
2
1. lambda$mod$95048fc1$5 : negated conditional → KILLED 2. lambda$mod$95048fc1$5 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$mod$95048fc1$5 → KILLED |
(v1, v2) -> v2.shortValue() == 0 ? ExprNullValue.of() : |
309 |
1
1. lambda$mod$95048fc1$5 : Replaced float modulus with multiplication → KILLED |
new ExprFloatValue(v1.floatValue() % v2.floatValue())), |
310 | FLOAT, FLOAT, FLOAT), | |
311 | FunctionDSL.impl( | |
312 | FunctionDSL.nullMissingHandling( | |
313 |
2
1. lambda$mod$95048fc1$6 : negated conditional → KILLED 2. lambda$mod$95048fc1$6 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$mod$95048fc1$6 → KILLED |
(v1, v2) -> v2.shortValue() == 0 ? ExprNullValue.of() : |
314 |
1
1. lambda$mod$95048fc1$6 : Replaced double modulus with multiplication → KILLED |
new ExprDoubleValue(v1.doubleValue() % v2.doubleValue())), |
315 | DOUBLE, DOUBLE, DOUBLE) | |
316 | ); | |
317 | } | |
318 | ||
319 | /** | |
320 | * Definition of pi() function. | |
321 | * Get the value of pi. | |
322 | * () -> DOUBLE | |
323 | */ | |
324 | private static DefaultFunctionResolver pi() { | |
325 |
1
1. pi : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::pi → KILLED |
return FunctionDSL.define(BuiltinFunctionName.PI.getName(), |
326 |
1
1. lambda$pi$19cc14d4$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$pi$19cc14d4$1 → KILLED |
FunctionDSL.impl(() -> new ExprDoubleValue(Math.PI), DOUBLE) |
327 | ); | |
328 | } | |
329 | ||
330 | /** | |
331 | * Definition of pow(x, y)/power(x, y) function. | |
332 | * Calculate the value of x raised to the power of y | |
333 | * The supported signature of pow/power function is | |
334 | * (INTEGER, INTEGER) -> DOUBLE | |
335 | * (LONG, LONG) -> DOUBLE | |
336 | * (FLOAT, FLOAT) -> DOUBLE | |
337 | * (DOUBLE, DOUBLE) -> DOUBLE | |
338 | */ | |
339 | private static DefaultFunctionResolver pow() { | |
340 |
1
1. pow : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::pow → KILLED |
return FunctionDSL.define(BuiltinFunctionName.POW.getName(), powerFunctionImpl()); |
341 | } | |
342 | ||
343 | private static DefaultFunctionResolver power() { | |
344 |
1
1. power : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::power → KILLED |
return FunctionDSL.define(BuiltinFunctionName.POWER.getName(), powerFunctionImpl()); |
345 | } | |
346 | ||
347 | private List<SerializableFunction<FunctionName, Pair<FunctionSignature, | |
348 | FunctionBuilder>>> powerFunctionImpl() { | |
349 |
1
1. powerFunctionImpl : replaced return value with Collections.emptyList for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::powerFunctionImpl → SURVIVED |
return Arrays.asList(FunctionDSL.impl( |
350 | FunctionDSL.nullMissingHandling( | |
351 |
1
1. lambda$powerFunctionImpl$e9c56033$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$powerFunctionImpl$e9c56033$1 → KILLED |
(v1, v2) -> new ExprDoubleValue(Math.pow(v1.shortValue(), v2.shortValue()))), |
352 | DOUBLE, SHORT, SHORT), | |
353 | FunctionDSL.impl( | |
354 | FunctionDSL.nullMissingHandling( | |
355 |
1
1. lambda$powerFunctionImpl$e9c56033$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$powerFunctionImpl$e9c56033$2 → KILLED |
(v1, v2) -> new ExprDoubleValue(Math.pow(v1.integerValue(), |
356 | v2.integerValue()))), | |
357 | DOUBLE, INTEGER, INTEGER), | |
358 | FunctionDSL.impl( | |
359 | FunctionDSL.nullMissingHandling( | |
360 |
1
1. lambda$powerFunctionImpl$e9c56033$3 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$powerFunctionImpl$e9c56033$3 → KILLED |
(v1, v2) -> new ExprDoubleValue(Math.pow(v1.longValue(), v2.longValue()))), |
361 | DOUBLE, LONG, LONG), | |
362 | FunctionDSL.impl( | |
363 | FunctionDSL.nullMissingHandling( | |
364 |
1
1. lambda$powerFunctionImpl$e9c56033$4 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$powerFunctionImpl$e9c56033$4 → KILLED |
(v1, v2) -> new ExprDoubleValue(Math.pow(v1.floatValue(), v2.floatValue()))), |
365 | DOUBLE, FLOAT, FLOAT), | |
366 | FunctionDSL.impl( | |
367 | FunctionDSL.nullMissingHandling( | |
368 |
1
1. lambda$powerFunctionImpl$e9c56033$5 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$powerFunctionImpl$e9c56033$5 → KILLED |
(v1, v2) -> new ExprDoubleValue(Math.pow(v1.doubleValue(), v2.doubleValue()))), |
369 | DOUBLE, DOUBLE, DOUBLE)); | |
370 | } | |
371 | ||
372 | /** | |
373 | * Definition of rand() and rand(N) function. | |
374 | * rand() returns a random floating-point value in the range 0 <= value < 1.0 | |
375 | * If integer N is specified, the seed is initialized prior to execution. | |
376 | * One implication of this behavior is with identical argument N,rand(N) returns the same value | |
377 | * each time, and thus produces a repeatable sequence of column values. | |
378 | * The supported signature of rand function is | |
379 | * ([INTEGER]) -> FLOAT | |
380 | */ | |
381 | private static DefaultFunctionResolver rand() { | |
382 |
1
1. rand : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::rand → KILLED |
return FunctionDSL.define(BuiltinFunctionName.RAND.getName(), |
383 |
1
1. lambda$rand$19cc14d4$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$rand$19cc14d4$1 → KILLED |
FunctionDSL.impl(() -> new ExprFloatValue(new Random().nextFloat()), FLOAT), |
384 | FunctionDSL.impl( | |
385 | FunctionDSL.nullMissingHandling( | |
386 |
1
1. lambda$rand$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$rand$12c7dc48$1 → KILLED |
v -> new ExprFloatValue(new Random(v.integerValue()).nextFloat())), FLOAT, INTEGER) |
387 | ); | |
388 | } | |
389 | ||
390 | /** | |
391 | * Definition of round(x)/round(x, d) function. | |
392 | * Rounds the argument x to d decimal places, d defaults to 0 if not specified. | |
393 | * The supported signature of round function is | |
394 | * (x: INTEGER [, y: INTEGER]) -> INTEGER | |
395 | * (x: LONG [, y: INTEGER]) -> LONG | |
396 | * (x: FLOAT [, y: INTEGER]) -> FLOAT | |
397 | * (x: DOUBLE [, y: INTEGER]) -> DOUBLE | |
398 | */ | |
399 | private static DefaultFunctionResolver round() { | |
400 |
1
1. round : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::round → KILLED |
return FunctionDSL.define(BuiltinFunctionName.ROUND.getName(), |
401 | // rand(x) | |
402 | FunctionDSL.impl( | |
403 | FunctionDSL.nullMissingHandling( | |
404 |
1
1. lambda$round$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$12c7dc48$1 → KILLED |
v -> new ExprLongValue((long) Math.round(v.integerValue()))), |
405 | LONG, INTEGER), | |
406 | FunctionDSL.impl( | |
407 | FunctionDSL.nullMissingHandling( | |
408 |
1
1. lambda$round$12c7dc48$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$12c7dc48$2 → KILLED |
v -> new ExprLongValue((long) Math.round(v.longValue()))), |
409 | LONG, LONG), | |
410 | FunctionDSL.impl( | |
411 | FunctionDSL.nullMissingHandling( | |
412 |
1
1. lambda$round$12c7dc48$3 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$12c7dc48$3 → KILLED |
v -> new ExprDoubleValue((double) Math.round(v.floatValue()))), |
413 | DOUBLE, FLOAT), | |
414 | FunctionDSL.impl( | |
415 | FunctionDSL.nullMissingHandling( | |
416 |
1
1. lambda$round$12c7dc48$4 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$12c7dc48$4 → KILLED |
v -> new ExprDoubleValue(new BigDecimal(v.doubleValue()).setScale(0, |
417 | RoundingMode.HALF_UP).doubleValue())), | |
418 | DOUBLE, DOUBLE), | |
419 | ||
420 | // rand(x, d) | |
421 | FunctionDSL.impl( | |
422 | FunctionDSL.nullMissingHandling( | |
423 |
1
1. lambda$round$95048fc1$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$95048fc1$1 → KILLED |
(x, d) -> new ExprLongValue( |
424 | new BigDecimal(x.integerValue()).setScale(d.integerValue(), | |
425 | RoundingMode.HALF_UP).longValue())), | |
426 | LONG, INTEGER, INTEGER), | |
427 | FunctionDSL.impl( | |
428 | FunctionDSL.nullMissingHandling( | |
429 |
1
1. lambda$round$95048fc1$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$95048fc1$2 → KILLED |
(x, d) -> new ExprLongValue(new BigDecimal(x.longValue()).setScale(d.integerValue(), |
430 | RoundingMode.HALF_UP).longValue())), | |
431 | LONG, LONG, INTEGER), | |
432 | FunctionDSL.impl( | |
433 | FunctionDSL.nullMissingHandling( | |
434 |
1
1. lambda$round$95048fc1$3 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$95048fc1$3 → KILLED |
(x, d) -> new ExprDoubleValue(new BigDecimal(x.floatValue()) |
435 | .setScale(d.integerValue(), RoundingMode.HALF_UP).doubleValue())), | |
436 | DOUBLE, FLOAT, INTEGER), | |
437 | FunctionDSL.impl( | |
438 | FunctionDSL.nullMissingHandling( | |
439 |
1
1. lambda$round$95048fc1$4 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$round$95048fc1$4 → KILLED |
(x, d) -> new ExprDoubleValue(new BigDecimal(x.doubleValue()) |
440 | .setScale(d.integerValue(), RoundingMode.HALF_UP).doubleValue())), | |
441 | DOUBLE, DOUBLE, INTEGER)); | |
442 | } | |
443 | ||
444 | /** | |
445 | * Definition of sign(x) function. | |
446 | * Returns the sign of the argument as -1, 0, or 1 | |
447 | * depending on whether x is negative, zero, or positive | |
448 | * The supported signature is | |
449 | * SHORT/INTEGER/LONG/FLOAT/DOUBLE -> INTEGER | |
450 | */ | |
451 | private static DefaultFunctionResolver sign() { | |
452 |
1
1. sign : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::sign → KILLED |
return FunctionDSL.define(BuiltinFunctionName.SIGN.getName(), |
453 | ExprCoreType.numberTypes().stream() | |
454 |
1
1. lambda$sign$4 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$sign$4 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
455 |
1
1. lambda$sign$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$sign$12c7dc48$1 → KILLED |
v -> new ExprIntegerValue(Math.signum(v.doubleValue()))), |
456 | INTEGER, type)).collect(Collectors.toList())); | |
457 | } | |
458 | ||
459 | /** | |
460 | * Definition of sqrt(x) function. | |
461 | * Calculate the square root of a non-negative number x | |
462 | * The supported signature is | |
463 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
464 | */ | |
465 | private static DefaultFunctionResolver sqrt() { | |
466 |
1
1. sqrt : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::sqrt → KILLED |
return FunctionDSL.define(BuiltinFunctionName.SQRT.getName(), |
467 | ExprCoreType.numberTypes().stream() | |
468 |
1
1. lambda$sqrt$5 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$sqrt$5 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
469 |
3
1. lambda$sqrt$12c7dc48$1 : changed conditional boundary → SURVIVED 2. lambda$sqrt$12c7dc48$1 : negated conditional → KILLED 3. lambda$sqrt$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$sqrt$12c7dc48$1 → KILLED |
v -> v.doubleValue() < 0 ? ExprNullValue.of() : |
470 | new ExprDoubleValue(Math.sqrt(v.doubleValue()))), | |
471 | DOUBLE, type)).collect(Collectors.toList())); | |
472 | } | |
473 | ||
474 | /** | |
475 | * Definition of truncate(x, d) function. | |
476 | * Returns the number x, truncated to d decimal places | |
477 | * The supported signature of round function is | |
478 | * (x: INTEGER, y: INTEGER) -> LONG | |
479 | * (x: LONG, y: INTEGER) -> LONG | |
480 | * (x: FLOAT, y: INTEGER) -> DOUBLE | |
481 | * (x: DOUBLE, y: INTEGER) -> DOUBLE | |
482 | */ | |
483 | private static DefaultFunctionResolver truncate() { | |
484 |
1
1. truncate : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::truncate → KILLED |
return FunctionDSL.define(BuiltinFunctionName.TRUNCATE.getName(), |
485 | FunctionDSL.impl( | |
486 | FunctionDSL.nullMissingHandling( | |
487 |
1
1. lambda$truncate$95048fc1$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$truncate$95048fc1$1 → KILLED |
(x, y) -> new ExprLongValue( |
488 | new BigDecimal(x.integerValue()).setScale(y.integerValue(), | |
489 | RoundingMode.DOWN).longValue())), | |
490 | LONG, INTEGER, INTEGER), | |
491 | FunctionDSL.impl( | |
492 | FunctionDSL.nullMissingHandling( | |
493 |
1
1. lambda$truncate$95048fc1$2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$truncate$95048fc1$2 → KILLED |
(x, y) -> new ExprLongValue( |
494 | new BigDecimal(x.integerValue()).setScale(y.integerValue(), | |
495 | RoundingMode.DOWN).longValue())), | |
496 | LONG, LONG, INTEGER), | |
497 | FunctionDSL.impl( | |
498 | FunctionDSL.nullMissingHandling( | |
499 |
1
1. lambda$truncate$95048fc1$3 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$truncate$95048fc1$3 → KILLED |
(x, y) -> new ExprDoubleValue( |
500 | new BigDecimal(x.floatValue()).setScale(y.integerValue(), | |
501 | RoundingMode.DOWN).doubleValue())), | |
502 | DOUBLE, FLOAT, INTEGER), | |
503 | FunctionDSL.impl( | |
504 | FunctionDSL.nullMissingHandling( | |
505 |
1
1. lambda$truncate$95048fc1$4 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$truncate$95048fc1$4 → KILLED |
(x, y) -> new ExprDoubleValue( |
506 | new BigDecimal(x.doubleValue()).setScale(y.integerValue(), | |
507 | RoundingMode.DOWN).doubleValue())), | |
508 | DOUBLE, DOUBLE, INTEGER)); | |
509 | } | |
510 | ||
511 | /** | |
512 | * Definition of acos(x) function. | |
513 | * Calculates the arc cosine of x, that is, the value whose cosine is x. | |
514 | * Returns NULL if x is not in the range -1 to 1. | |
515 | * The supported signature of acos function is | |
516 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
517 | */ | |
518 | private static DefaultFunctionResolver acos() { | |
519 |
1
1. acos : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::acos → KILLED |
return FunctionDSL.define(BuiltinFunctionName.ACOS.getName(), |
520 | ExprCoreType.numberTypes().stream() | |
521 |
1
1. lambda$acos$6 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$acos$6 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
522 |
5
1. lambda$acos$12c7dc48$1 : changed conditional boundary → SURVIVED 2. lambda$acos$12c7dc48$1 : changed conditional boundary → KILLED 3. lambda$acos$12c7dc48$1 : negated conditional → KILLED 4. lambda$acos$12c7dc48$1 : negated conditional → KILLED 5. lambda$acos$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$acos$12c7dc48$1 → KILLED |
v -> v.doubleValue() < -1 || v.doubleValue() > 1 ? ExprNullValue.of() : |
523 | new ExprDoubleValue(Math.acos(v.doubleValue()))), | |
524 | DOUBLE, type)).collect(Collectors.toList())); | |
525 | } | |
526 | ||
527 | /** | |
528 | * Definition of asin(x) function. | |
529 | * Calculates the arc sine of x, that is, the value whose sine is x. | |
530 | * Returns NULL if x is not in the range -1 to 1. | |
531 | * The supported signature of asin function is | |
532 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
533 | */ | |
534 | private static DefaultFunctionResolver asin() { | |
535 |
1
1. asin : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::asin → KILLED |
return FunctionDSL.define(BuiltinFunctionName.ASIN.getName(), |
536 | ExprCoreType.numberTypes().stream() | |
537 |
1
1. lambda$asin$7 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$asin$7 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
538 |
5
1. lambda$asin$12c7dc48$1 : changed conditional boundary → SURVIVED 2. lambda$asin$12c7dc48$1 : changed conditional boundary → KILLED 3. lambda$asin$12c7dc48$1 : negated conditional → KILLED 4. lambda$asin$12c7dc48$1 : negated conditional → KILLED 5. lambda$asin$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$asin$12c7dc48$1 → KILLED |
v -> v.doubleValue() < -1 || v.doubleValue() > 1 ? ExprNullValue.of() : |
539 | new ExprDoubleValue(Math.asin(v.doubleValue()))), | |
540 | DOUBLE, type)).collect(Collectors.toList())); | |
541 | } | |
542 | ||
543 | /** | |
544 | * Definition of atan(x) and atan(y, x) function. | |
545 | * atan(x) calculates the arc tangent of x, that is, the value whose tangent is x. | |
546 | * atan(y, x) calculates the arc tangent of y / x, except that the signs of both arguments | |
547 | * are used to determine the quadrant of the result. | |
548 | * The supported signature of atan function is | |
549 | * (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) -> DOUBLE | |
550 | */ | |
551 | private static DefaultFunctionResolver atan() { | |
552 | ImmutableList.Builder<SerializableFunction<FunctionName, Pair<FunctionSignature, | |
553 | FunctionBuilder>>> builder = new ImmutableList.Builder<>(); | |
554 | ||
555 | for (ExprType type : ExprCoreType.numberTypes()) { | |
556 | builder.add(FunctionDSL.impl(FunctionDSL | |
557 |
1
1. lambda$atan$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$atan$12c7dc48$1 → KILLED |
.nullMissingHandling(x -> new ExprDoubleValue(Math.atan(x.doubleValue()))), type, |
558 | DOUBLE)); | |
559 | builder.add(FunctionDSL.impl(FunctionDSL | |
560 |
1
1. lambda$atan$95048fc1$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$atan$95048fc1$1 → KILLED |
.nullMissingHandling((y, x) -> new ExprDoubleValue(Math.atan2(y.doubleValue(), |
561 | x.doubleValue()))), DOUBLE, type, type)); | |
562 | } | |
563 | ||
564 |
1
1. atan : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::atan → KILLED |
return FunctionDSL.define(BuiltinFunctionName.ATAN.getName(), builder.build()); |
565 | } | |
566 | ||
567 | /** | |
568 | * Definition of atan2(y, x) function. | |
569 | * Calculates the arc tangent of y / x, except that the signs of both arguments | |
570 | * are used to determine the quadrant of the result. | |
571 | * The supported signature of atan2 function is | |
572 | * (x: INTEGER/LONG/FLOAT/DOUBLE, y: INTEGER/LONG/FLOAT/DOUBLE) -> DOUBLE | |
573 | */ | |
574 | private static DefaultFunctionResolver atan2() { | |
575 | ImmutableList.Builder<SerializableFunction<FunctionName, Pair<FunctionSignature, | |
576 | FunctionBuilder>>> builder = new ImmutableList.Builder<>(); | |
577 | ||
578 | for (ExprType type : ExprCoreType.numberTypes()) { | |
579 | builder.add(FunctionDSL.impl(FunctionDSL | |
580 |
1
1. lambda$atan2$95048fc1$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$atan2$95048fc1$1 → KILLED |
.nullMissingHandling((y, x) -> new ExprDoubleValue(Math.atan2(y.doubleValue(), |
581 | x.doubleValue()))), DOUBLE, type, type)); | |
582 | } | |
583 | ||
584 |
1
1. atan2 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::atan2 → KILLED |
return FunctionDSL.define(BuiltinFunctionName.ATAN2.getName(), builder.build()); |
585 | } | |
586 | ||
587 | /** | |
588 | * Definition of cos(x) function. | |
589 | * Calculates the cosine of X, where X is given in radians | |
590 | * The supported signature of cos function is | |
591 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
592 | */ | |
593 | private static DefaultFunctionResolver cos() { | |
594 |
1
1. cos : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::cos → KILLED |
return FunctionDSL.define(BuiltinFunctionName.COS.getName(), |
595 | ExprCoreType.numberTypes().stream() | |
596 |
1
1. lambda$cos$8 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$cos$8 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
597 |
1
1. lambda$cos$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$cos$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.cos(v.doubleValue()))), |
598 | DOUBLE, type)).collect(Collectors.toList())); | |
599 | } | |
600 | ||
601 | /** | |
602 | * Definition of cot(x) function. | |
603 | * Calculates the cotangent of x | |
604 | * The supported signature of cot function is | |
605 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
606 | */ | |
607 | private static DefaultFunctionResolver cot() { | |
608 |
1
1. cot : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::cot → KILLED |
return FunctionDSL.define(BuiltinFunctionName.COT.getName(), |
609 | ExprCoreType.numberTypes().stream() | |
610 |
1
1. lambda$cot$9 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$cot$9 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
611 | v -> { | |
612 | Double value = v.doubleValue(); | |
613 |
1
1. lambda$cot$12c7dc48$1 : negated conditional → KILLED |
if (value == 0) { |
614 | throw new ArithmeticException( | |
615 | String.format("Out of range value for cot(%s)", value)); | |
616 | } | |
617 |
2
1. lambda$cot$12c7dc48$1 : Replaced double division with multiplication → KILLED 2. lambda$cot$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$cot$12c7dc48$1 → KILLED |
return new ExprDoubleValue(1 / Math.tan(value)); |
618 | }), | |
619 | DOUBLE, type)).collect(Collectors.toList())); | |
620 | } | |
621 | ||
622 | /** | |
623 | * Definition of degrees(x) function. | |
624 | * Converts x from radians to degrees | |
625 | * The supported signature of degrees function is | |
626 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
627 | */ | |
628 | private static DefaultFunctionResolver degrees() { | |
629 |
1
1. degrees : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::degrees → KILLED |
return FunctionDSL.define(BuiltinFunctionName.DEGREES.getName(), |
630 | ExprCoreType.numberTypes().stream() | |
631 |
1
1. lambda$degrees$10 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$degrees$10 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
632 |
1
1. lambda$degrees$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$degrees$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.toDegrees(v.doubleValue()))), |
633 | type, DOUBLE)).collect(Collectors.toList())); | |
634 | } | |
635 | ||
636 | /** | |
637 | * Definition of radians(x) function. | |
638 | * Converts x from degrees to radians | |
639 | * The supported signature of radians function is | |
640 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
641 | */ | |
642 | private static DefaultFunctionResolver radians() { | |
643 |
1
1. radians : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::radians → KILLED |
return FunctionDSL.define(BuiltinFunctionName.RADIANS.getName(), |
644 | ExprCoreType.numberTypes().stream() | |
645 |
1
1. lambda$radians$11 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$radians$11 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
646 |
1
1. lambda$radians$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$radians$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.toRadians(v.doubleValue()))), |
647 | DOUBLE, type)).collect(Collectors.toList())); | |
648 | } | |
649 | ||
650 | /** | |
651 | * Definition of sin(x) function. | |
652 | * Calculates the sine of x, where x is given in radians | |
653 | * The supported signature of sin function is | |
654 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
655 | */ | |
656 | private static DefaultFunctionResolver sin() { | |
657 |
1
1. sin : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::sin → KILLED |
return FunctionDSL.define(BuiltinFunctionName.SIN.getName(), |
658 | ExprCoreType.numberTypes().stream() | |
659 |
1
1. lambda$sin$12 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$sin$12 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
660 |
1
1. lambda$sin$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$sin$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.sin(v.doubleValue()))), |
661 | DOUBLE, type)).collect(Collectors.toList())); | |
662 | } | |
663 | ||
664 | /** | |
665 | * Definition of tan(x) function. | |
666 | * Calculates the tangent of x, where x is given in radians | |
667 | * The supported signature of tan function is | |
668 | * INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE | |
669 | */ | |
670 | private static DefaultFunctionResolver tan() { | |
671 |
1
1. tan : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::tan → KILLED |
return FunctionDSL.define(BuiltinFunctionName.TAN.getName(), |
672 | ExprCoreType.numberTypes().stream() | |
673 |
1
1. lambda$tan$13 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$tan$13 → KILLED |
.map(type -> FunctionDSL.impl(FunctionDSL.nullMissingHandling( |
674 |
1
1. lambda$tan$12c7dc48$1 : replaced return value with null for org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction::lambda$tan$12c7dc48$1 → KILLED |
v -> new ExprDoubleValue(Math.tan(v.doubleValue()))), |
675 | DOUBLE, type)).collect(Collectors.toList())); | |
676 | } | |
677 | } | |
Mutations | ||
54 |
1.1 |
|
55 |
1.1 |
|
56 |
1.1 |
|
57 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
65 |
1.1 |
|
66 |
1.1 |
|
67 |
1.1 |
|
68 |
1.1 |
|
69 |
1.1 |
|
70 |
1.1 |
|
71 |
1.1 |
|
72 |
1.1 |
|
73 |
1.1 |
|
74 |
1.1 |
|
75 |
1.1 |
|
76 |
1.1 |
|
77 |
1.1 |
|
78 |
1.1 |
|
79 |
1.1 |
|
80 |
1.1 |
|
81 |
1.1 |
|
82 |
1.1 |
|
83 |
1.1 |
|
84 |
1.1 |
|
92 |
1.1 |
|
94 |
1.1 |
|
97 |
1.1 |
|
100 |
1.1 |
|
103 |
1.1 |
|
106 |
1.1 |
|
109 |
1.1 |
|
119 |
1.1 |
|
121 |
1.1 |
|
127 |
1.1 |
|
129 |
1.1 |
|
142 |
1.1 |
|
144 |
1.1 |
|
150 |
1.1 |
|
165 |
1.1 |
|
169 |
1.1 |
|
170 |
1.1 |
|
182 |
1.1 |
|
183 |
1.1 |
|
192 |
1.1 |
|
194 |
1.1 |
|
195 |
1.1 |
|
204 |
1.1 |
|
206 |
1.1 |
|
216 |
1.1 |
|
218 |
1.1 |
|
219 |
1.1 |
|
235 |
1.1 |
|
243 |
1.1 |
|
244 |
1.1 |
|
248 |
1.1 |
|
257 |
1.1 |
|
259 |
1.1 |
|
260 |
1.1 |
|
269 |
1.1 |
|
271 |
1.1 |
|
272 |
1.1 2.2 |
|
284 |
1.1 |
|
287 |
1.1 2.2 |
|
288 |
1.1 |
|
292 |
1.1 2.2 |
|
293 |
1.1 |
|
297 |
1.1 2.2 |
|
303 |
1.1 2.2 |
|
308 |
1.1 2.2 |
|
309 |
1.1 |
|
313 |
1.1 2.2 |
|
314 |
1.1 |
|
325 |
1.1 |
|
326 |
1.1 |
|
340 |
1.1 |
|
344 |
1.1 |
|
349 |
1.1 |
|
351 |
1.1 |
|
355 |
1.1 |
|
360 |
1.1 |
|
364 |
1.1 |
|
368 |
1.1 |
|
382 |
1.1 |
|
383 |
1.1 |
|
386 |
1.1 |
|
400 |
1.1 |
|
404 |
1.1 |
|
408 |
1.1 |
|
412 |
1.1 |
|
416 |
1.1 |
|
423 |
1.1 |
|
429 |
1.1 |
|
434 |
1.1 |
|
439 |
1.1 |
|
452 |
1.1 |
|
454 |
1.1 |
|
455 |
1.1 |
|
466 |
1.1 |
|
468 |
1.1 |
|
469 |
1.1 2.2 3.3 |
|
484 |
1.1 |
|
487 |
1.1 |
|
493 |
1.1 |
|
499 |
1.1 |
|
505 |
1.1 |
|
519 |
1.1 |
|
521 |
1.1 |
|
522 |
1.1 2.2 3.3 4.4 5.5 |
|
535 |
1.1 |
|
537 |
1.1 |
|
538 |
1.1 2.2 3.3 4.4 5.5 |
|
557 |
1.1 |
|
560 |
1.1 |
|
564 |
1.1 |
|
580 |
1.1 |
|
584 |
1.1 |
|
594 |
1.1 |
|
596 |
1.1 |
|
597 |
1.1 |
|
608 |
1.1 |
|
610 |
1.1 |
|
613 |
1.1 |
|
617 |
1.1 2.2 |
|
629 |
1.1 |
|
631 |
1.1 |
|
632 |
1.1 |
|
643 |
1.1 |
|
645 |
1.1 |
|
646 |
1.1 |
|
657 |
1.1 |
|
659 |
1.1 |
|
660 |
1.1 |
|
671 |
1.1 |
|
673 |
1.1 |
|
674 |
1.1 |