functions_arithmetic_decimal.yaml¶
This document file is generated for functions_arithmetic_decimal.yaml. The extension URN is extension:io.substrait:functions_arithmetic_decimal.
Scalar Functions¶
add¶
Add two decimal values.
Implementations:
- add(
x: decimal<P1,S1>,y: decimal<P2,S2>,option:overflow): ->init_scale = max(S1,S2) init_prec = init_scale + max(P1 - S1, P2 - S2) + 1 min_scale = min(init_scale, 6) delta = init_prec - 38 prec = min(init_prec, 38) scale_after_borrow = max(init_scale - delta, min_scale) scale = init_prec > 38 ? scale_after_borrow : init_scale DECIMAL<prec, scale>
Options:
subtract¶
Implementations:
- subtract(
x: decimal<P1,S1>,y: decimal<P2,S2>,option:overflow): ->init_scale = max(S1,S2) init_prec = init_scale + max(P1 - S1, P2 - S2) + 1 min_scale = min(init_scale, 6) delta = init_prec - 38 prec = min(init_prec, 38) scale_after_borrow = max(init_scale - delta, min_scale) scale = init_prec > 38 ? scale_after_borrow : init_scale DECIMAL<prec, scale>
Options:
multiply¶
Implementations:
- multiply(
x: decimal<P1,S1>,y: decimal<P2,S2>,option:overflow): ->init_scale = S1 + S2 init_prec = P1 + P2 + 1 min_scale = min(init_scale, 6) delta = init_prec - 38 prec = min(init_prec, 38) scale_after_borrow = max(init_scale - delta, min_scale) scale = init_prec > 38 ? scale_after_borrow : init_scale DECIMAL<prec, scale>
Options:
divide¶
Implementations:
- divide(
x: decimal<P1,S1>,y: decimal<P2,S2>,option:overflow): ->init_scale = max(6, S1 + P2 + 1) init_prec = P1 - S1 + P2 + init_scale min_scale = min(init_scale, 6) delta = init_prec - 38 prec = min(init_prec, 38) scale_after_borrow = max(init_scale - delta, min_scale) scale = init_prec > 38 ? scale_after_borrow : init_scale DECIMAL<prec, scale>
Options:
modulus¶
Implementations:
- modulus(
x: decimal<P1,S1>,y: decimal<P2,S2>,option:overflow): ->init_scale = max(S1,S2) init_prec = min(P1 - S1, P2 - S2) + init_scale min_scale = min(init_scale, 6) delta = init_prec - 38 prec = min(init_prec, 38) scale_after_borrow = max(init_scale - delta, min_scale) scale = init_prec > 38 ? scale_after_borrow : init_scale DECIMAL<prec, scale>
Options:
abs¶
Calculate the absolute value of the argument.
Implementations:
- abs(
x: decimal<P,S>): ->decimal<P,S>
bitwise_and¶
Return the bitwise AND result for two decimal inputs. In inputs scale must be 0 (i.e. only integer types are allowed)
Implementations:
- bitwise_and(
x: DECIMAL<P1,0>,y: DECIMAL<P2,0>): ->max_precision = max(P1, P2) DECIMAL<max_precision, 0>
bitwise_or¶
Return the bitwise OR result for two given decimal inputs. In inputs scale must be 0 (i.e. only integer types are allowed)
Implementations:
- bitwise_or(
x: DECIMAL<P1,0>,y: DECIMAL<P2,0>): ->max_precision = max(P1, P2) DECIMAL<max_precision, 0>
bitwise_xor¶
Return the bitwise XOR result for two given decimal inputs. In inputs scale must be 0 (i.e. only integer types are allowed)
Implementations:
- bitwise_xor(
x: DECIMAL<P1,0>,y: DECIMAL<P2,0>): ->max_precision = max(P1, P2) DECIMAL<max_precision, 0>
sqrt¶
Square root of the value. Sqrt of 0 is 0 and sqrt of negative values will raise an error.
Implementations:
- sqrt(
x: DECIMAL<P,S>): ->fp64
factorial¶
Return the factorial of a given decimal input. Scale should be 0 for factorial decimal input. The factorial of 0! is 1 by convention. Negative inputs will raise an error. Input which cause overflow of result will raise an error.
Implementations:
- factorial(
n: DECIMAL<P,0>): ->DECIMAL<38,0>
power¶
Take the power with x as the base and y as exponent. Behavior for complex number result is indicated by option complex_number_result
Implementations:
- power(
x: DECIMAL<P1,S1>,y: DECIMAL<P2,S2>,option:overflow,option:complex_number_result): ->fp64
Options:
Aggregate Functions¶
sum¶
Sum a set of values.
Implementations:
- sum(
x: DECIMAL<P, S>,option:overflow): ->DECIMAL?<38,S>
Options:
avg¶
Average a set of values.
Implementations:
- avg(
x: DECIMAL<P,S>,option:overflow): ->DECIMAL<38,S>
Options:
min¶
Min a set of values.
Implementations:
- min(
x: DECIMAL<P, S>): ->DECIMAL?<P, S>
max¶
Max a set of values.
Implementations:
- max(
x: DECIMAL<P,S>): ->DECIMAL?<P, S>
sum0¶
Sum a set of values. The sum of zero elements yields zero. Null values are ignored.
Implementations:
- sum0(
x: DECIMAL<P, S>,option:overflow): ->DECIMAL<38,S>