The mathematical functions in Apache Impala come in handy during data analysis, especially when it comes to revenue or monetary calculations. These math functions are applicable to applications that use Trigonometry, Calculus, and Geometry. Arithmetic functions like ABS, CEILING, DEGREES, FLOOR, POWER, RADIANS, and SIGN return the same data type as the input value.
Let’s do some practical exercises:
Power: This function returns the value of x raised to the power of Y.
Mod: The first input is divided by the second, and the remainder is returned.
Abs: This function returns the absolute value of X.
Ceil: This function returns the smallest integer value that is either greater than or equal to the input value.
Floor: This function returns the largest integer value that is less than or equal to the input value.
Least: This function returns the value with the lowest value in the provided array.
Greatest: This function returns the value with the highest value in the provided array.
Precision & Scale: Computes the precision (number of decimal digits) needed to represent the type of the argument expression as a DECIMAL value.
SELECT PRECISION(9), SCALE(9);
Returns 3 and 0.
SELECT PRECISION(9.00812), SCALE(9.00812);
Returns 6 and 5.
Sign: The function SIGN returns 1 if the given input is positive, -1 if the input value is negative, and 0 if it is zero.
Hope you find this article helpful.
Please subscribe for more interesting updates.