Skip to content

Commit

Permalink
feat: add functions for arithmetic, rounding, logarithmic, and string…
Browse files Browse the repository at this point in the history
… transformations (#245)

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

Co-authored-by: Sanjiban Sengupta <[email protected]>
  • Loading branch information
gforsyth and sanjibansg committed Jul 25, 2022
1 parent 42d9ca3 commit f7c5da5
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 1 deletion.
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."
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"
description: "Square root 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: 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. The sum of zero elements yields null.
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 ]
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
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

0 comments on commit f7c5da5

Please sign in to comment.