Applies to: Databricks SQL Databricks Runtime
Returns the rounded
HALF_EVEN rounding mode.
expr: A numeric expression.
targetScale: An INTEGER constant expression. If
targetScaleis omitted the default is 0 (whole number).
In Databricks SQL and Databricks Runtime 12.2 and later: If
targetscaleis negative rounding is performed to positive powers of
expr is DECIMAL the result is DECIMAL with a scale that is the smaller of
expr scale and
For all other numeric types the result type matches
HALF_EVEN rounding, also known as Gaussian or banker’s rounding, the digit
5 is rounded towards an even digit.
HALF_UP rounding use the round function.
Prior to Databricks Runtime 13.0, and in Databricks Runtime if spark.sql.ansi.enabled is
false, an overflow does not cause an error but “wraps” the result instead.