Skip to content

Commit

Permalink
feat: add arithmetic function "sqrt" and "factorial" with decimal type
Browse files Browse the repository at this point in the history
  • Loading branch information
anshuldata committed Jul 31, 2024
1 parent da3c74e commit 6b3250e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion extensions/functions_arithmetic_decimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ scalar_functions:
scale_after_borrow = max(init_scale - delta, min_scale)
scale = init_prec > 38 ? scale_after_borrow : init_scale
DECIMAL<prec, scale>
-
-
name: "abs"
description: Calculate the absolute value of the argument.
impls:
Expand All @@ -111,6 +111,23 @@ scalar_functions:
value: decimal<P,S>
return: decimal<P,S>

- name: "sqrt"
description: Square root of the value. Sqrt of 0 is 0 and sqrt of negative values will raise an error.
impls:
- args:
- name: x
value: "DECIMAL<P,S>"
return: fp64
- name: "factorial"
description: >
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.
impls:
- args:
- name: "n"
value: "DECIMAL<P,0>"
return: "DECIMAL<38,0>"
aggregate_functions:
- name: "sum"
description: Sum a set of values.
Expand Down

0 comments on commit 6b3250e

Please sign in to comment.