-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases for aggregate arithmetic function "sum/min/max/avg" ha…
…ving decimal argumets
- Loading branch information
1 parent
0c946db
commit 96dbadb
Showing
11 changed files
with
396 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from decimal import Decimal | ||
|
||
from bft.utils.utils import compareDecimalResult | ||
|
||
|
||
def test_compare_decimal_result(): | ||
assert compareDecimalResult(Decimal('1'), Decimal('1')) | ||
assert compareDecimalResult(Decimal('99999999999999999999999999999999999999'), Decimal('99999999999999999999999999999999999999')) | ||
assert compareDecimalResult(Decimal('1.75'), Decimal('1.75678')) | ||
assert compareDecimalResult(Decimal('1.757'), Decimal('1.75678')) == False | ||
assert compareDecimalResult(Decimal('2.33'), Decimal('2.330000000078644688')) | ||
assert compareDecimalResult(Decimal('4.12500053644180'), Decimal('4.1250005364418029785156')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
base_uri: https://github.com/substrait-io/substrait/blob/main/extensions/substrait/extensions/functions_arithmetic_decimal.yaml | ||
function: avg | ||
cases: | ||
- group: | ||
id: basic | ||
description: Basic examples without any special cases | ||
args: | ||
- value: [0, -1, 2, 20] | ||
type: decimal<38, 0> | ||
result: | ||
value: 5.25 | ||
type: decimal<38, 2> | ||
- group: basic | ||
args: | ||
- value: [2000000, -3217908, 629000, -100000, 0, 987654] | ||
type: decimal<38, 0> | ||
result: | ||
value: 49791 | ||
type: decimal<38, 5> | ||
- group: basic | ||
args: | ||
- value: [2.5, 0, 5.0, -2.5, -7.5] | ||
type: decimal<38, 2> | ||
result: | ||
value: -0.5 | ||
type: decimal<38, 2> | ||
- group: basic | ||
args: | ||
- value: [2.5000007152557373046875, 7.0000007152557373046875, 0, 7.0000007152557373046875] | ||
type: decimal<38, 22> | ||
result: | ||
value: 4.12500053644180 | ||
type: decimal<38, 22> | ||
- group: | ||
id: overflow | ||
description: Examples demonstrating overflow behavior | ||
args: | ||
- value: [99999999999999999999999999999999999999, 1, 1, 1, 1, 99999999999999999999999999999999999999] | ||
type: decimal<38, 0> | ||
options: | ||
overflow: ERROR | ||
result: | ||
special: error | ||
- group: | ||
id: null_handling | ||
description: Examples with null as unput or output | ||
args: | ||
- value: [Null, Null, Null] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [200000, Null, 629000, -10000, 0, 987621] | ||
type: decimal<38, 0> | ||
result: | ||
value: 361324.2 | ||
type: decimal<38, 2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
base_uri: https://github.com/substrait-io/substrait/blob/main/extensions/substrait/extensions/functions_arithmetic_decimal.yaml | ||
function: max | ||
cases: | ||
- group: | ||
id: basic | ||
description: Basic examples without any special cases | ||
args: | ||
- value: [20, -3, 1, -10, 0, 5] | ||
type: decimal<38, 0> | ||
result: | ||
value: 20 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [-32768, 32767, 20000, -30000] | ||
type: decimal<38, 0> | ||
result: | ||
value: 32767 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [-214748648, 214748647, 21470048, 4000000] | ||
type: decimal<38, 0> | ||
result: | ||
value: 214748647 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [2000000000, -3217908979, 629000000, -100000000, 0, 987654321] | ||
type: decimal<38, 0> | ||
result: | ||
value: 2000000000 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [2.5, 0, 5.0, -2.5, -7.5] | ||
type: decimal<38, 2> | ||
result: | ||
value: 5.0 | ||
type: decimal<38, 2> | ||
- group: basic | ||
args: | ||
- value: [99999999999999999999999999999999999999, 0, -99999999999999999999999999999999999998, 111111111, -76] | ||
type: decimal<38, 0> | ||
result: | ||
value: 99999999999999999999999999999999999999 | ||
type: decimal<38, 0> | ||
- group: | ||
id: null_handling | ||
description: Examples with null as unput or output | ||
args: | ||
- value: [Null, Null, Null] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [2000000000, Null, 629000000, -100000000, Null, 987654321] | ||
type: decimal<38, 0> | ||
result: | ||
value: 2000000000 | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [Null, Null] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [99999999999999999999999999999999999999, -99999999999999999999999999999999999998, Null, 11111111111111111111111111111111111111, Null] | ||
type: decimal<38, 0> | ||
result: | ||
value: 99999999999999999999999999999999999999 | ||
type: decimal<38, 0> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
base_uri: https://github.com/substrait-io/substrait/blob/main/extensions/substrait/extensions/functions_arithmetic_decimal.yaml | ||
function: min | ||
cases: | ||
- group: | ||
id: basic | ||
description: Basic examples without any special cases | ||
args: | ||
- value: [20, -3, 1, -10, 0, 5] | ||
type: decimal<38, 0> | ||
result: | ||
value: -10 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [-32768, 32767, 20000, -30000] | ||
type: decimal<38, 0> | ||
result: | ||
value: -32768 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [-214748648, 214748647, 21470048, 4000000] | ||
type: decimal<38, 0> | ||
result: | ||
value: -214748648 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [2000000000, -3217908979, 629000000, -100000000, 0, 987654321] | ||
type: decimal<38, 0> | ||
result: | ||
value: -3217908979 | ||
type: decimal<38, 0> | ||
- group: basic | ||
args: | ||
- value: [2.5, 0, 5.0, -2.5, -7.5] | ||
type: decimal<38, 2> | ||
result: | ||
value: -7.5 | ||
type: decimal<38, 2> | ||
- group: basic | ||
args: | ||
- value: [99999999999999999999999999999999999999, -99999999999999999999999999999999999998, -99999999999999999999999999999999999997, 0, 1111] | ||
type: decimal<38, 0> | ||
result: | ||
value: -99999999999999999999999999999999999998 | ||
type: decimal<38, 0> | ||
- group: | ||
id: null_handling | ||
description: Examples with null as unput or output | ||
args: | ||
- value: [Null, Null, Null] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [] | ||
type: decimal<38, 0> | ||
result: | ||
value: Null | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [2000000000, Null, 629000000, -100000000, Null, 987654321] | ||
type: decimal<38, 0> | ||
result: | ||
value: -100000000 | ||
type: decimal<38, 0> | ||
- group: null_handling | ||
args: | ||
- value: [-99999999999999999999999999999999999998, Null, 99999999999999999999999999999999999999, Null] | ||
type: decimal<38, 0> | ||
result: | ||
value: -99999999999999999999999999999999999998 | ||
type: decimal<38, 0> |
Oops, something went wrong.