Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add functions for arithmetic, rounding, logarithmic, and string transformations #245

Merged
merged 13 commits into from
Jul 25, 2022
Merged
79 changes: 79 additions & 0 deletions extensions/functions_arithmetic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,36 @@ scalar_functions:
- value: fp64
- value: fp64
return: fp64
-
name: "negate"
description: "Negation of the value"
impls:
- args:
- options: [ SILENT, SATURATE, ERROR ]
required: false
- value: i8
return: i8
- args:
- options: [ SILENT, SATURATE, ERROR ]
required: false
- value: i16
return: i16
- args:
- options: [ SILENT, SATURATE, ERROR ]
required: false
- value: i32
return: i32
- args:
- options: [ SILENT, SATURATE, ERROR ]
required: false
- value: i64
return: i64
- args:
- value: fp32
return: fp32
- args:
- value: fp64
return: fp64
-
name: "modulus"
description: "Get the remainder when dividing one value by another."
gforsyth marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -181,6 +211,55 @@ scalar_functions:
- value: i64
- value: i64
return: i64
-
name: "power"
description: "Take the power with the first value as the base and second as exponent."
impls:
- args:
- options: [ SILENT, SATURATE, ERROR ]
required: false
- value: i64
- value: i64
return: i64
- args:
- value: fp32
- value: fp32
return: fp32
- args:
- value: fp64
- value: fp64
return: fp64
-
name: "sqrt"
gforsyth marked this conversation as resolved.
Show resolved Hide resolved
description: "Square root of the value"
gforsyth marked this conversation as resolved.
Show resolved Hide resolved
impls:
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: i64
return: fp64
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp32
return: fp32
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp64
return: fp64
aggregate_functions:
- name: "sum"
description: Sum a set of values.
Expand Down
10 changes: 10 additions & 0 deletions extensions/functions_comparison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ scalar_functions:
- value: any1
return: BOOLEAN
nullability: DECLARED_OUTPUT
-
name: "is_nan"
description: Whether a value is not a number.
impls:
- args:
- value: fp32
return: BOOLEAN
- args:
- value: fp64
return: BOOLEAN

106 changes: 106 additions & 0 deletions extensions/functions_logarithmic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
%YAML 1.2
---
scalar_functions:
-
name: "ln"
description: "Natural logarithm of the value"
impls:
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp32
return: fp32
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
jacques-n marked this conversation as resolved.
Show resolved Hide resolved
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp64
return: fp64
-
name: "log10"
description: "Logarithm to base 10 of the value"
impls:
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp32
return: fp32
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp64
return: fp64
-
name: "log2"
description: "Logarithm to base 2 of the value"
impls:
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp32
return: fp32
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp64
return: fp64
-
name: "logb"
description: >
Logarithm of the value with the given base

logb(x, b) => log_{b} (x)
impls:
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp32
gforsyth marked this conversation as resolved.
Show resolved Hide resolved
name: "x"
description: "The number `x` to compute the logarithm of"
- value: fp32
name: "base"
description: "The logarithm base `b` to use"
return: fp32
- args:
- name: rounding
options: [ TIE_TO_EVEN, TIE_AWAY_FROM_ZERO, TRUNCATE, CEILING, FLOOR ]
required: false
- name: on_domain_error
options: [ NAN, ERROR ]
required: false
- value: fp64
name: "x"
description: "The number `x` to compute the logarithm of"
- value: fp64
name: "base"
description: "The logarithm base `b` to use"
return: fp64


23 changes: 23 additions & 0 deletions extensions/functions_rounding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%YAML 1.2
---
scalar_functions:
-
name: "ceil"
description: "Rounding to the ceiling of the value"
impls:
- args:
- value: fp32
return: fp32
- args:
- value: fp64
return: fp64
-
name: "floor"
description: "Rounding to the floor of the value"
impls:
- args:
- value: fp32
return: fp32
- args:
- value: fp64
return: fp64
3 changes: 2 additions & 1 deletion extensions/functions_string.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ scalar_functions:
- value: i32
- value: i32
return: "string"
- name: starts_with
-
name: starts_with
description: Whether this string starts with another string.
impls:
- args:
Expand Down