From 348a7b76f5feb77e798d3afeeee18bead467c4b6 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Wed, 27 Sep 2023 17:38:32 -0400 Subject: [PATCH] chore: upgrade substrait to v0.34.0 (#23) --- src/substrait/__init__.py | 4 +- .../extensions/functions_arithmetic.yaml | 138 ++++++++++++++++++ third_party/substrait | 2 +- 3 files changed, 141 insertions(+), 3 deletions(-) diff --git a/src/substrait/__init__.py b/src/substrait/__init__.py index b891f05..98ab722 100644 --- a/src/substrait/__init__.py +++ b/src/substrait/__init__.py @@ -3,6 +3,6 @@ except ImportError: pass -__substrait_version__ = "0.32.0" -__substrait_hash__ = "31b99906" +__substrait_version__ = "0.34.0" +__substrait_hash__ = "dacc5a9" __minimum_substrait_version__ = "0.30.0" diff --git a/src/substrait/extensions/functions_arithmetic.yaml b/src/substrait/extensions/functions_arithmetic.yaml index dd67a66..74a3f99 100644 --- a/src/substrait/extensions/functions_arithmetic.yaml +++ b/src/substrait/extensions/functions_arithmetic.yaml @@ -1654,3 +1654,141 @@ window_functions: decomposable: NONE return: i64? window_type: PARTITION + - name: "first_value" + description: > + Returns the first value in the window. + impls: + - args: + - value: any1 + name: expression + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1 + window_type: PARTITION + - name: "last_value" + description: > + Returns the last value in the window. + impls: + - args: + - value: any1 + name: expression + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1 + window_type: PARTITION + - name: "nth_value" + description: > + Returns a value from the nth row based on the `window_offset`. `window_offset` should + be a positive integer. If the value of the `window_offset` is outside the range + of the window, `null` is returned. + + The `on_domain_error` option governs behavior in cases where `window_offset` is not + a positive integer or `null`. + impls: + - args: + - value: any1 + name: expression + - value: i32 + name: window_offset + options: + on_domain_error: + values: [ NAN, ERROR ] + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1? + window_type: PARTITION + - name: "lead" + description: > + Return a value from a following row based on a specified physical offset. + This allows you to compare a value in the current row against a following row. + + The `expression` is evaluated against a row that comes after the current row based + on the `row_offset`. The `row_offset` should be a positive integer and is set to + 1 if not specified explicitly. If the `row_offset` is negative, the expression + will be evaluated against a row coming before the current row, similar to the `lag` + function. A `row_offset` of `null` will return `null`. The function returns the + `default` input value if `row_offset` goes beyond the scope of the window. + If a `default` value is not specified, it is set to `null`. + + Example comparing the sales of the current year to the following year. + `row_offset` of 1. + | year | sales | next_year_sales | + | 2019 | 20.50 | 30.00 | + | 2020 | 30.00 | 45.99 | + | 2021 | 45.99 | null | + impls: + - args: + - value: any1 + name: expression + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1? + window_type: PARTITION + - args: + - value: any1 + name: expression + - value: i32 + name: row_offset + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1? + window_type: PARTITION + - args: + - value: any1 + name: expression + - value: i32 + name: row_offset + - value: any1 + name: default + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1? + window_type: PARTITION + - name: "lag" + description: > + Return a column value from a previous row based on a specified physical offset. + This allows you to compare a value in the current row against a previous row. + + The `expression` is evaluated against a row that comes before the current row based + on the `row_offset`. The `expression` can be a column, expression or subquery that + evaluates to a single value. The `row_offset` should be a positive integer and is set to + 1 if not specified explicitly. If the `row_offset` is negative, the expression will + be evaluated against a row coming after the current row, similar to the `lead` function. + A `row_offset` of `null` will return `null`. The function returns the `default` + input value if `row_offset` goes beyond the scope of the partition. If a `default` + value is not specified, it is set to `null`. + + Example comparing the sales of the current year to the previous year. + `row_offset` of 1. + | year | sales | previous_year_sales | + | 2019 | 20.50 | null | + | 2020 | 30.00 | 20.50 | + | 2021 | 45.99 | 30.00 | + impls: + - args: + - value: any1 + name: expression + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1? + window_type: PARTITION + - args: + - value: any1 + name: expression + - value: i32 + name: row_offset + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1? + window_type: PARTITION + - args: + - value: any1 + name: expression + - value: i32 + name: row_offset + - value: any1 + name: default + nullability: DECLARED_OUTPUT + decomposable: NONE + return: any1? + window_type: PARTITION diff --git a/third_party/substrait b/third_party/substrait index 51765cc..dacc5a9 160000 --- a/third_party/substrait +++ b/third_party/substrait @@ -1 +1 @@ -Subproject commit 51765cccd92fa0014e9cf077cc8cc952731f33d0 +Subproject commit dacc5a96a17fe45aed228f7819de3aa8a404a8b0