Skip to content

Commit fd30ff7

Browse files
committed
comments
1 parent c5bdd94 commit fd30ff7

File tree

1 file changed

+7
-1
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math

1 file changed

+7
-1
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@
2929
import java.util.Map;
3030

3131
/**
32-
* ES|QL function that mimics the behavior of Math.copySign(double magnitude, double sign).
32+
* ES|QL function that mimics the behavior of {@code Math.copySign(double magnitude, double sign)}.
3333
* Returns a value with the magnitude of the first argument and the sign of the second argument.
34+
*
35+
* <p>
36+
* The output of this function is the MAGNITUDE with the SIGN from `sign` applied to it.
37+
* For that reason, we cast the SIGN to DOUBLE, which is the most general numeric type,
38+
* and allows us to write a single check (<0 or >=0) for all possible types of `sign`.
39+
* However, the output type of this function is determined by the `magnitude` type.
3440
*/
3541
public class CopySign extends EsqlScalarFunction {
3642

0 commit comments

Comments
 (0)