Type to search.

ES|QL COPY_SIGN function

Serverless

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack 9.1+

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available since 9.1

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Combines the magnitude of one number with the sign of another.

Embedded
Embedded
magnitude
The expression providing the magnitude of the result. Must be a numeric type.
sign

The expression providing the sign of the result. Must be a numeric type.

Returns a value with the magnitude of the first argument and the sign of the second argument. This function is similar to Java's Math.copySign(double magnitude, double sign) which is similar to copysign from IEEE 754.

magnitude sign result
double double double
double integer double
double long double
integer double integer
integer integer integer
integer long integer
long double long
long integer long
long long long
ES|QL
FROM employees
| EVAL cs1 = COPY_SIGN(salary, LEAST(salary_change))
emp_no:integer salary:integer salary_change:double cs1:integer
10001 57305 1.19 57305
10002 56371 [-7.23, 11.17] -56371
10003 61805 [12.82, 14.68] 61805