diff --git a/src/substrait/__init__.py b/src/substrait/__init__.py index 99075de..cb7df01 100644 --- a/src/substrait/__init__.py +++ b/src/substrait/__init__.py @@ -3,6 +3,6 @@ except ImportError: pass -__substrait_version__ = "0.40.0" -__substrait_hash__ = "cdae23e" +__substrait_version__ = "0.41.0" +__substrait_hash__ = "c7d7e9c" __minimum_substrait_version__ = "0.30.0" diff --git a/src/substrait/extensions/functions_arithmetic.yaml b/src/substrait/extensions/functions_arithmetic.yaml index 74a3f99..fbfc1f7 100644 --- a/src/substrait/extensions/functions_arithmetic.yaml +++ b/src/substrait/extensions/functions_arithmetic.yaml @@ -285,31 +285,84 @@ scalar_functions: return: fp64 - name: "modulus" - description: "Get the remainder when dividing one value by another." + description: > + Calculate the remainder (r) when dividing dividend (x) by divisor (y). + + In mathematics, many conventions for the modulus (mod) operation exists. The result of a mod operation + depends on the software implementation and underlying hardware. Substrait is a format for describing compute + operations on structured data and designed for interoperability. Therefore the user is responsible for determining + a definition of division as defined by the quotient (q). + + The following basic conditions of division are satisfied: + (1) q ∈ ℤ (the quotient is an integer) + (2) x = y * q + r (division rule) + (3) abs(r) < abs(y) + where q is the quotient. + + The `division_type` option determines the mathematical definition of quotient to use in the above definition of + division. + + When `division_type`=TRUNCATE, q = trunc(x/y). + When `division_type`=FLOOR, q = floor(x/y). + + In the cases of TRUNCATE and FLOOR division: remainder r = x - round_func(x/y) + + The `on_domain_error` option governs behavior in cases where y is 0, y is +/-inf, or x is +/-inf. In these cases + the mod is undefined. + The `overflow` option governs behavior when integer overflow occurs. + If x and y are both 0 or both +/-infinity, behavior will be governed by `on_domain_error`. impls: - args: - name: x value: i8 - name: y value: i8 + options: + division_type: + values: [ TRUNCATE, FLOOR ] + overflow: + values: [ SILENT, SATURATE, ERROR ] + on_domain_error: + values: [ "NULL", ERROR ] return: i8 - args: - name: x value: i16 - name: y value: i16 + options: + division_type: + values: [ TRUNCATE, FLOOR ] + overflow: + values: [ SILENT, SATURATE, ERROR ] + on_domain_error: + values: [ "NULL", ERROR ] return: i16 - args: - name: x value: i32 - name: y value: i32 + options: + division_type: + values: [ TRUNCATE, FLOOR ] + overflow: + values: [ SILENT, SATURATE, ERROR ] + on_domain_error: + values: [ "NULL", ERROR ] return: i32 - args: - name: x value: i64 - name: y value: i64 + options: + division_type: + values: [ TRUNCATE, FLOOR ] + overflow: + values: [ SILENT, SATURATE, ERROR ] + on_domain_error: + values: [ "NULL", ERROR ] return: i64 - name: "power" diff --git a/third_party/substrait b/third_party/substrait index cdae23e..c7d7e9c 160000 --- a/third_party/substrait +++ b/third_party/substrait @@ -1 +1 @@ -Subproject commit cdae23ea0f5784243efa60a5361fabf31127457f +Subproject commit c7d7e9c5393aaa5e63b4a18ce65e423faa5eb9dd