Math Functions
- Abs
- Acos
- Asin
- Atan
- Atan2
- Atan2_left_arg_double
- Atan2_right_arg_double
- Bround
- Bround_with_scale
- Cbrt
- Ceil
- Conv
- Cos
- Cosh
- Degrees
- Exp
- Expm1
- Factorial
- Floor
- Format_number
- Greatest
- Hex
- Hypot
- Hypot_left_arg_double
- Hypot_right_arg_double
- Least
- Log
- Log1p
- Log_with_base
- Negate
- Pmod
- Pow
- Pow_left_arg_double
- Pow_right_arg_double
- Radians
- Rand
- Rand_with_seed
- Randn
- Randn_with_seed
- Rint
- Round
- Round_with_scale
- Signum
- Sin
- Sinh
- SqlSqrt
- Tan
- Tanh
- ToDegrees
- ToRadians
In this article
- Abs
- Acos
- Asin
- Atan
- Atan2
- Atan2_left_arg_double
- Atan2_right_arg_double
- Bround
- Bround_with_scale
- Cbrt
- Ceil
- Conv
- Cos
- Cosh
- Degrees
- Exp
- Expm1
- Factorial
- Floor
- Format_number
- Greatest
- Hex
- Hypot
- Hypot_left_arg_double
- Hypot_right_arg_double
- Least
- Log
- Log1p
- Log_with_base
- Negate
- Pmod
- Pow
- Pow_left_arg_double
- Pow_right_arg_double
- Radians
- Rand
- Rand_with_seed
- Randn
- Randn_with_seed
- Rint
- Round
- Round_with_scale
- Signum
- Sin
- Sinh
- SqlSqrt
- Tan
- Tanh
- ToDegrees
- ToRadians
Abs
Computes the absolute value.
Input Parameters: Column arg0
arg0 (required) - The column for which absolute value to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed absolute value. |
Throws | Application Exception |
Use Case:
Example:
abs(77.76)
will return 77.76
Acos
Computes the cosine inverse of the given value; the returned angle is in the range 0.0 through pi.
Input Parameters: Column arg0
arg0 (required) - The column for which cosine inverse to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed cosine inverse in the range 0.0 through pi. |
Throws | Application Exception |
Use Case:
Example:
acos(0.45)
will return 1.104031001096478
Asin
Computes the sine inverse of the given value; the returned angle is in the range -pi/2 through pi/2.
Input Parameters: Column arg0
arg0 (required) - The column for which sine inverse to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed sine inverse in the range -pi/2 through pi/2. |
Throws | Application Exception |
Use Case:
Example:
asin(0.45)
will return 0.4667653256984187
Atan
Computes the tangent inverse of the given value.
Input Parameters: Column arg0
arg0 (required) - The column for which tangent inverse to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed the tangent inverse. |
Throws | Application Exception |
Example:
atan(0.45)
will return 0.42285391621948626
Atan2
Computes the angle theta from the conversion of rectangular coordinates (arg0, arg1) to polar coordinates (arg1, theta).
Input Parameters: Column arg0, Column arg1
arg0 (required) - The column for the x rectangular coordinate.
arg1 (required) - The column for the y rectangular coordinate.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed angle theta. |
Throws | Application Exception |
Use Case:
Example:
atan2(12, 71.21)
will return 1.403849169952035
Atan2_left_arg_double
Computes the angle theta from the conversion of rectangular coordinates (arg0, arg1) to polar coordinates (arg1, theta).
Input Parameters: double arg0, Column arg1
arg0 (required) - The x rectangular coordinate.
arg1 (required) - The column for the y rectangular coordinate.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed angle theta. |
Throws | Application Exception |
Use Case:
Example:
atan2_left_arg_double(12, 71.21)
will return 1.403849169952035
Atan2_right_arg_double
Computes the angle theta from the conversion of rectangular coordinates (arg0, arg1) to polar coordinates (arg1, theta).
Input Parameters: Column arg0, double arg1
arg0 (required) - The column for the x rectangular coordinate.
arg1 (required) - The y rectangular coordinate.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed angle theta. |
Throws | Application Exception |
Use Case:
Example:
atan2_right_arg_double(12, 71.21)
will return 1.403849169952035.
Bround
Computes the value of the column arg0 rounded to 0 decimal places with HALF_EVEN round mode.
Input Parameters: Column arg0
arg0 (required) - The column for which value rounded to 0 decimal places with HALF_EVEN round mode to be calculated
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed value |
Throws | Application Exception |
Use Case:
Example:
bround(71.21)
will return 71.0
Bround_with_scale
Round the value of arg0 to arg1 decimal places with HALF_EVEN round mode if arg1 is greater than or equal to 0 or at integral part when arg1 is less than 0.
Input Parameters: Column arg0, int arg1
arg0 (required) - The column for which value rounded to 0 decimal places with HALF_EVEN round mode to be calculated.
arg1 (required) - The scale to use
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed value. |
Throws | Application Exception |
Use Case:
Example:
bround_with_scale(71.21, 1)
will return 71.2.
Cbrt
Computes the cube-root of the given column.
Input Parameters: Column arg0
arg0 (required) - The column for which cube-root to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed cube-root. |
Throws | Application Exception |
Use Case:
Example:
cbrt(80.89)
will return 4.324789202233814
Ceil
Computes the ceiling of the given column.
Input Parameters: Column arg0
- arg0 (required) - The column for which ceiling to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed ceiling. |
Throws | Application Exception |
Example:
ceil(77.76)
will return 4.2682720044742055
Conv
Converts a number column from a given base to another.
Input Parameters: Column arg0,Column args1,Column args2
arg0 (required) - A number/String number column
arg1 (required) - Integer column of base from which a number is to be converted
arg2 (required) - Integer column of base to which a number is to be converted.
Output Type | String Column |
---|---|
Configuration Parameters | No |
Returns | The string in the target base. |
Throws | Application Exception |
Use Case:
Example:
conv(258,10,2)
will return 100000010
Cos
Computes the cosine of the given value.
Input Parameters: Column arg0
- arg0 (required) - The column for which cosine to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed cosine. |
Throws | Application Exception |
Use Case:
Example:
cos(76.56)
will return 0.3977126102073901
Cosh
Computes the hyperbolic cosine of the given value.
Input Parameters: Column arg0
- arg0 (required) -The column for which hyperbolic cosine to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed hyperbolic cosine. |
Throws | Application Exception |
Use Case:
Example:
cos(76.56)
will return 0.3977126102073901
Degrees
Converts an angle measured in radians to an approximately equivalent angle measured in degrees.
Input Parameters: Column arg0
- arg0 (required) -The column for which the equivalent angle measured in degrees to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The converted angle measured in degrees. |
Throws | Application Exception |
Use Case:
Example:
degrees(71.21)
will return 4080.0324066707394
Exp
Computes the exponential of the given value.
Input Parameters: Column arg0
- arg0 (required) -The column for which exponential to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed exponential. |
Throws | Application Exception |
Use Case:
Example:
exp(0.78)
will return 2.18147220308578
Expm1
Computes the exponential of the given value minus one.
Input Parameters: Column arg0
- arg0 (required) -The column for which exponential minus one to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed value. |
Throws | Application Exception |
Use Case:
Example:
expm1(0.23)
will return 0.2586000151807663
Factorial
Computes the factorial of the given value.
Input Parameters: Column arg0
- arg0 (required) -The column for which factorial to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The computed factorial. |
Throws | Application Exception |
Use Case:
Example:
factorial(11)
will return 39916800
Floor
Computes the floor of the given column.
Input Parameters: Column arg0
- arg0 (required) -The column for which floor to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed floor. |
Throws | Application Exception |
Use Case:
Example:
floor(71.21)
will return 71
Format_number
Formats numeric column arg0 to a format like ‘#,###,###.##’, rounded to arg1 decimal places, and returns the result as a string column.
Input Parameters: Column arg0, int arg1
arg0 (required) -The column to be formated.
arg1 (required) -The integer specifying the decimal places to be used for rounding.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the formatted result as a string column. |
Throws | Application Exception |
Example:
format_number(7120.12, 1)
will return 7,120.1
Greatest
It gives the greatest value of the list of values. This function takes at least 2 parameters.
Input Parameters: Column arg0,Column args1,…
arg0 (required) -A column from the schema
arg1 (required) -A column from the schema
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | The greatest column |
Throws | Application Exception |
Use Case:
Example:
greatest(258,259)
will return 259
Hex
If the argument is an INT, hex returns the number as a STRING in hexadecimal format. Otherwise if the number is a STRING, it converts each character into its hexadecimal representation and returns the resulting STRING.
Input Parameters: Column arg0
- arg0 (required) -A int/string column
Output Type | String Column |
---|---|
Configuration Parameters | No |
Returns | A string value. |
Throws | Application Exception |
Use Case:
Example:
hex(258)
will return 102
Hypot
Computes sqrt(arg0^2^ + arg1^2^) without intermediate overflow or underflow.
Input Parameters: Column arg0, Column arg1
arg0 (required) -Will be used while computing sqrt.
arg1 (required) -Will be used while computing sqrt.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed sqrt(arg0^2^ + arg1^2^). |
Throws | Application Exception |
Use Case:
Example:
hypot(71.21, 10.5)
will return 71.97995533209642
Hypot_left_arg_double
Computes sqrt(arg0^2^ + arg1^2^) without intermediate overflow or underflow.
Input Parameters: double arg0, Column arg1
arg0 (required) -Will be used while computing sqrt.
arg1 (required) -Will be used while computing sqrt.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed sqrt(arg0^2^ + arg1^2^). |
Throws | Application Exception |
Use Case:
Example:
hypot_left_arg_double(71.21, 10.5)
will return 71.97995533209642
Hypot_right_arg_double
Computes sqrt(arg0^2^ + arg1^2^) without intermediate overflow or underflow.
Input Parameters: Column arg0, double arg1
arg0 (required) -Will be used while computing sqrt.
arg1 (required) -Will be used while computing sqrt.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed sqrt(arg0^2^ + arg1^2^). |
Throws | Application Exception |
Use Case:
Example:
hypot_right_arg_double(71.21, 10.5)
will return 71.97995533209642
Least
It gives the least value of the list of values. This function takes at least 2 parameters.
Input Parameters: Column arg0,Column args1,…
arg0 (required) - A column from the schema.
arg1 (required) - A column from the schema.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the least column |
Throws | Application Exception |
Use Case:
Example:
least(258,259)
will return 259
Log
Computes the natural logarithm of the given value.
Input Parameters: Column arg0
- arg0 (required) - The column for which natural logarithm to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed natural logarithm. |
Throws | Application Exception |
Use Case:
Example:
log(20)
will return 2.995732273553991
Log1p
Computes the natural logarithm of the given value plus one.
Input Parameters: Column arg0
- arg0 (required) - The column for which natural logarithm plus one to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed natural logarithm plus one. |
Throws | Application Exception |
Example:
log1p(20)
will return 3.044522437723423
Log_with_base
Computes the first argument-base logarithm of the second argument.
Input Parameters: double arg0, Column arg1
arg0 (required) - The base to used.
arg1 (required) - The column for which logarithm to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed algorithm. |
Throws | Application Exception |
Use Case:
Example:
log_with_base(10, 20)
will return 1.301029995663981
Negate
Computes the Unary minus, i.e. -(arg0)
Input Parameters: Column arg0
- arg0 (required) - The column for which unary minus to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed Unary minus, i.e. -(arg0). |
Throws | Application Exception |
Example:
negate(20)
will return -20
Pmod
Computes the positive value of arg0 mod arg1.
Input Parameters: Column arg0, Column arg1
arg0 (required) - The dividend.
arg1 (required) - The divisor.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed positive value of arg0 mod arg1. |
Throws | Application Exception |
Use Case:
Example:
pmod(19, 0.78)
will return 0.2800007
Pow
Computes the value of the first argument raised to the power of the second argument.
Input Parameters: Column arg0, Column arg1
arg0 (required) - The base.
arg1 (required) - The exponent.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed value |
Throws | Application Exception |
Use Case:
Example:
pow(20, 2)
will return 400
Pow_left_arg_double
Computes the value of the first argument raised to the power of the second argument.
Input Parameters: double arg0, Column arg1
arg0 (required) - The base.
arg1 (required) - The exponent
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the compute value |
Throws | Application Exception |
Use Case:
Example:
pow_left_arg_double(20, 2)
will return 400
Pow_right_arg_double
Computes the value of the first argument raised to the power of the second argument.
Input Parameters: Column arg0, double arg1
arg0 (required) - The base.
arg1 (required) - The exponent
Output Type | Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed value. |
Throws | Application Exception |
Use Case:
Example:
pow_right_arg_double(20, 2)
will return 400
Radians
Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
Input Parameters: Column arg0
- arg0 (required) - The column for which equivalent angle measured in radians to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the converted angle measured in radians. |
Throws | Application Exception |
Use Case:
Example:
radians(20)
will return 0.3490658503988659
Rand
Generate a random column with independent and identically distributed (i.i.d.) samples from 0.0 to 1.0.
Input Parameters: No input arguments.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the generated column. |
Throws | Application Exception |
Example:
rand()
will return a new column with independent and identically distributed (i.i.d.) samples from 0.0 to 1.0.
Rand_with_seed
Generate a random column with independent and identically distributed (i.i.d.) samples from 0.0 to 1.0.
Input Parameters: long arg0
- arg0 (required) - The seed
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the generated column. |
Throws | Application Exception |
Use Case:
Example:
rand_with_seed(2)
will return a new column with independent and identically distributed (i.i.d.) samples from 0.0 to 1.0.
Randn
Generate a column with independent and identically distributed (i.i.d.) samples from the standard normal distribution.
Input Parameters: No input arguments.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the generated column. |
Throws | Application Exception |
Use Case:
Example:
randn()
will return a new column with independent and identically distributed (i.i.d.) samples from the standard normal distribution.
Randn_with_seed
Generate a column with independent and identically distributed (i.i.d.) samples from the standard normal distribution.
Input Parameters: long arg0
- arg0 (required) - The seed
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the generated column. |
Throws | Application Exception |
Use Case:
Example:
randn_with_seed(2)
will return a new column with independent and identically distributed (i.i.d.) samples from the standard normal distribution.
Rint
Computes the double value that is closest in value to the argument and is equal to a mathematical integer.
Input Parameters: Column arg0
- arg0 (required) - The column for which double value to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed last day. |
Throws | Application Exception |
Use Case:
Example:
rint(80.89)
will return 81.0
Round
Computes the value of the column arg0 rounded to 0 decimal places.
Input Parameters: Column arg0
arg0 (required) - The column for which value rounded to 0 decimal places to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed value. |
Throws | Application Exception |
Use Case:
Example:
round(80.89)
will return 81.0
Round_with_scale
Computes the value of arg0 to scale decimal places if arg1 is greater than or equal to 0 or at integral part when arg1 is less than 0.
Input Parameters: Column arg0, int arg1
arg0 (required) - The column for which value rounded to 0 decimal places to be calculated.
arg0 (required) - The seed
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed value. |
Throws | Application Exception |
Use Case:
Example:
round_with_scale(80.89,1)
will return 80.9
Signum
Computes the signum of the given value.
Input Parameters: Column arg0
- arg0 (required) - The column for which signum to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed signum. |
Throws | Application Exception |
Example:
signum(20)
will return 1.0
Sin
Computes the sine of the given value.
Input Parameters: Column arg0
- arg0 (required) - The column for which sine to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed sine |
Throws | Application Exception |
Example:
sin(20)
will return 0.9129452507276277
Sinh
Computes the hyperbolic sine of the given value.
Input Parameters: Column arg0
- arg0 (required) - The column for which sine to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed hyperbolic sine. |
Throws | Application Exception |
Example:
sinh(20)
will return 2.4258259770489514E8
SqlSqrt
Computes the square root of the specified float value.
Input Parameters: Column arg0
- arg0 (required) - The column for which square root to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed square root. |
Throws | Application Exception |
Use Case:
Example:
sqlSqrt(20)
will return 4.47213595499958
Tan
Computes the tangent of the given value.
Input Parameters: Column arg0
arg0 (required) - The column for which tangent to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed tangent |
Throws | Application Exception |
Use Case:
Example:
tan(20)
will return 2.237160944224742
Tanh
Computes the hyperbolic tangent of the given value.
Input Parameters: Column arg0
- arg0 (required) - The column for which hyperbolic tangent to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the computed hyperbolic tangent. |
Throws | Application Exception |
Example:
tanh(20)
will return 1.0
ToDegrees
Computes the angle measured in radians to an approximately equivalent angle measured in degrees.
Input Parameters: Column arg0
- arg0 (required) - The column for which degree to be calculated
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the angle measured in degrees. |
Throws | Application Exception |
Use Case:
Example:
toDegrees(3.14159)
will return 180
ToRadians
Computes the angle measured in degrees to an approximately equivalent angle measured in radians.
Input Parameters: Column arg0
- arg0 (required) - A column for which radians to be calculated.
Output Type | Number Column |
---|---|
Configuration Parameters | No |
Returns | Returns the angle measured in radians. |
Throws | Application Exception |
Example:
toRadians(180)
will return 3.14159
If you have any feedback on Gathr documentation, please email us!