-
Notifications
You must be signed in to change notification settings - Fork 191
feat(extensions): add unsigned integer extension types (u8, u16, u32, u64) #953
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
base: main
Are you sure you want to change the base?
Changes from 22 commits
d19c87a
a413f3e
b4bd79b
719ddb5
37a1a40
41cee40
10baf81
078ddbc
0d4aa26
8d37e9e
ec638bf
b7990a8
a14d6d7
856e63d
dbd3c8e
62a4767
7f577ce
4bec245
215fcee
cd6b2a8
fce64b0
04a8882
7c4c54a
3ac870f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,309 @@ | ||
| %YAML 1.2 | ||
| --- | ||
| urn: "extension:io.substrait:unsigned_integers" | ||
|
|
||
| types: | ||
| - name: u8 | ||
| description: > | ||
| Unsigned 8-bit integer (0 to 255). | ||
| Values are encoded as decimal strings in the structure representation. | ||
| structure: | ||
| value: str | ||
| - name: u16 | ||
| description: > | ||
| Unsigned 16-bit integer (0 to 65535). | ||
| Values are encoded as decimal strings in the structure representation. | ||
| structure: | ||
| value: str | ||
| - name: u32 | ||
| description: > | ||
| Unsigned 32-bit integer (0 to 4294967295). | ||
| Values are encoded as decimal strings in the structure representation. | ||
| structure: | ||
| value: str | ||
| - name: u64 | ||
| description: > | ||
| Unsigned 64-bit integer (0 to 18446744073709551615). | ||
| Values are encoded as decimal strings in the structure representation. | ||
| structure: | ||
| value: str | ||
|
|
||
| scalar_functions: | ||
|
vbarua marked this conversation as resolved.
|
||
| - | ||
| name: "add" | ||
| description: "Add two unsigned integer values." | ||
| impls: | ||
| - args: | ||
| - name: x | ||
| value: u!u8 | ||
| - name: y | ||
| value: u!u8 | ||
| options: | ||
| overflow: | ||
|
kadinrabo marked this conversation as resolved.
|
||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u8 | ||
| - args: | ||
| - name: x | ||
| value: u!u16 | ||
| - name: y | ||
| value: u!u16 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u16 | ||
| - args: | ||
| - name: x | ||
| value: u!u32 | ||
| - name: y | ||
| value: u!u32 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u32 | ||
| - args: | ||
| - name: x | ||
| value: u!u64 | ||
| - name: y | ||
| value: u!u64 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u64 | ||
| - | ||
| name: "subtract" | ||
| description: "Subtract one unsigned integer value from another." | ||
| impls: | ||
| - args: | ||
| - name: x | ||
| value: u!u8 | ||
| - name: y | ||
| value: u!u8 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u8 | ||
| - args: | ||
| - name: x | ||
| value: u!u16 | ||
| - name: y | ||
| value: u!u16 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u16 | ||
| - args: | ||
| - name: x | ||
| value: u!u32 | ||
| - name: y | ||
| value: u!u32 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u32 | ||
| - args: | ||
| - name: x | ||
| value: u!u64 | ||
| - name: y | ||
| value: u!u64 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u64 | ||
| - | ||
| name: "multiply" | ||
| description: "Multiply two unsigned integer values." | ||
| impls: | ||
| - args: | ||
| - name: x | ||
| value: u!u8 | ||
| - name: y | ||
| value: u!u8 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u8 | ||
| - args: | ||
| - name: x | ||
| value: u!u16 | ||
| - name: y | ||
| value: u!u16 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u16 | ||
| - args: | ||
| - name: x | ||
| value: u!u32 | ||
| - name: y | ||
| value: u!u32 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u32 | ||
| - args: | ||
| - name: x | ||
| value: u!u64 | ||
| - name: y | ||
| value: u!u64 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| return: u!u64 | ||
| - | ||
| name: "divide" | ||
| description: > | ||
| Divide x by y. Partial values are truncated (i.e. rounded towards 0). | ||
| The `on_division_by_zero` option governs behavior in cases where y is 0. | ||
| If either x or y are out of range, behavior will be governed by `on_domain_error`. | ||
| impls: | ||
| - args: | ||
| - name: x | ||
| value: u!u8 | ||
| - name: y | ||
| value: u!u8 | ||
| options: | ||
| on_domain_error: | ||
| values: [ "NULL", ERROR ] | ||
| on_division_by_zero: | ||
| values: [ "NULL", ERROR ] | ||
| return: u!u8 | ||
| - args: | ||
| - name: x | ||
| value: u!u16 | ||
| - name: y | ||
| value: u!u16 | ||
| options: | ||
| on_domain_error: | ||
| values: [ "NULL", ERROR ] | ||
| on_division_by_zero: | ||
| values: [ "NULL", ERROR ] | ||
| return: u!u16 | ||
| - args: | ||
| - name: x | ||
| value: u!u32 | ||
| - name: y | ||
| value: u!u32 | ||
| options: | ||
| on_domain_error: | ||
| values: [ "NULL", ERROR ] | ||
| on_division_by_zero: | ||
| values: [ "NULL", ERROR ] | ||
| return: u!u32 | ||
| - args: | ||
| - name: x | ||
| value: u!u64 | ||
| - name: y | ||
| value: u!u64 | ||
| options: | ||
| on_domain_error: | ||
| values: [ "NULL", ERROR ] | ||
| on_division_by_zero: | ||
| values: [ "NULL", ERROR ] | ||
| return: u!u64 | ||
|
|
||
| aggregate_functions: | ||
| - name: "sum" | ||
| description: Sum a set of unsigned integer values. The sum of zero elements yields null. | ||
|
kadinrabo marked this conversation as resolved.
|
||
| impls: | ||
| - args: | ||
| - name: x | ||
| value: u!u8 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u64? | ||
| return: u!u64? | ||
| - args: | ||
| - name: x | ||
| value: u!u16 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u64? | ||
| return: u!u64? | ||
| - args: | ||
| - name: x | ||
| value: u!u32 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u64? | ||
| return: u!u64? | ||
| - args: | ||
| - name: x | ||
| value: u!u64 | ||
| options: | ||
| overflow: | ||
| values: [ SILENT, SATURATE, ERROR ] | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u64? | ||
| return: u!u64? | ||
| - name: "min" | ||
| description: Min of a set of unsigned integer values. | ||
| impls: | ||
| - args: | ||
| - name: x | ||
| value: u!u8 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u8? | ||
| return: u!u8? | ||
| - args: | ||
| - name: x | ||
| value: u!u16 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u16? | ||
| return: u!u16? | ||
| - args: | ||
| - name: x | ||
| value: u!u32 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u32? | ||
| return: u!u32? | ||
| - args: | ||
| - name: x | ||
| value: u!u64 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u64? | ||
| return: u!u64? | ||
| - name: "max" | ||
| description: Max of a set of unsigned integer values. | ||
| impls: | ||
| - args: | ||
| - name: x | ||
| value: u!u8 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u8? | ||
| return: u!u8? | ||
| - args: | ||
| - name: x | ||
| value: u!u16 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u16? | ||
| return: u!u16? | ||
| - args: | ||
| - name: x | ||
| value: u!u32 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u32? | ||
| return: u!u32? | ||
| - args: | ||
| - name: x | ||
| value: u!u64 | ||
| nullability: DECLARED_OUTPUT | ||
| decomposable: MANY | ||
| intermediate: u!u64? | ||
| return: u!u64? | ||
|
kadinrabo marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| { | ||
| "registry": { | ||
| "extension_count": 15, | ||
| "dependency_count": 15, | ||
| "extension_count": 16, | ||
| "dependency_count": 18, | ||
| "function_count": 170, | ||
| "num_aggregate_functions": 29, | ||
| "num_scalar_functions": 166, | ||
| "num_aggregate_functions": 32, | ||
| "num_scalar_functions": 170, | ||
| "num_window_functions": 11, | ||
| "num_function_overloads": 529 | ||
| "num_function_overloads": 5013 | ||
| }, | ||
| "coverage": { | ||
| "total_test_count": 1136, | ||
| "num_function_variants": 529, | ||
| "num_covered_function_variants": 241 | ||
| "total_test_count": 1198, | ||
| "num_function_variants": 557, | ||
| "num_covered_function_variants": 269 | ||
| } | ||
| } |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to have null cases added to these tests? Might be overkill but can't hurt.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to keep parity with signed tests here, which don't have null cases for add/subtract/multiply either. Open to adding them if you feel strongly, but might be better as a follow up
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm okay with not doing this for now. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ### SUBSTRAIT_SCALAR_TEST: v1.0 | ||
|
vbarua marked this conversation as resolved.
|
||
| ### SUBSTRAIT_INCLUDE: '/extensions/unsigned_integers.yaml' | ||
|
|
||
| # basic: Basic unsigned integer examples | ||
| add('200'::u!u8, '50'::u!u8) = '250'::u!u8 | ||
| add('50000'::u!u16, '10000'::u!u16) = '60000'::u!u16 | ||
| add('3000000000'::u!u32, '1000000000'::u!u32) = '4000000000'::u!u32 | ||
| add('10000000000000000000'::u!u64, '1000000000000000000'::u!u64) = '11000000000000000000'::u!u64 | ||
|
|
||
| # overflow: Examples demonstrating overflow behavior | ||
| add('200'::u!u8, '100'::u!u8) [overflow:ERROR] = <!ERROR> | ||
| add('60000'::u!u16, '10000'::u!u16) [overflow:ERROR] = <!ERROR> | ||
| add('4000000000'::u!u32, '1000000000'::u!u32) [overflow:ERROR] = <!ERROR> | ||
| add('18446744073709551615'::u!u64, '1'::u!u64) [overflow:ERROR] = <!ERROR> | ||
| add('200'::u!u8, '100'::u!u8) [overflow:SATURATE] = '255'::u!u8 | ||
| add('200'::u!u8, '100'::u!u8) [overflow:SILENT] = <!UNDEFINED> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ### SUBSTRAIT_SCALAR_TEST: v1.0 | ||
| ### SUBSTRAIT_INCLUDE: '/extensions/unsigned_integers.yaml' | ||
|
|
||
| # basic: Basic unsigned integer examples | ||
| divide('250'::u!u8, '5'::u!u8) = '50'::u!u8 | ||
| divide('60000'::u!u16, '100'::u!u16) = '600'::u!u16 | ||
| divide('4000000000'::u!u32, '200'::u!u32) = '20000000'::u!u32 | ||
| divide('10000000000000000000'::u!u64, '5000'::u!u64) = '2000000000000000'::u!u64 | ||
|
|
||
| # division_by_zero: Examples demonstrating division by zero | ||
| divide('5'::u!u8, '0'::u!u8) [on_division_by_zero:NULL] = null::u!u8 | ||
| divide('5'::u!u8, '0'::u!u8) [on_division_by_zero:ERROR] = <!ERROR> |
Uh oh!
There was an error while loading. Please reload this page.