From 0961d79cb6ad4974b4421e795c0edb2915d7c693 Mon Sep 17 00:00:00 2001 From: Anshul Data Date: Thu, 22 Aug 2024 18:44:08 +0530 Subject: [PATCH] Add test cases for bitwise and/or/xor for decimal type --- cases/arithmetic_decimal/bitwise_and.yaml | 121 +++++++++++++++++ cases/arithmetic_decimal/bitwise_or.yaml | 143 ++++++++++++++++++++ cases/arithmetic_decimal/bitwise_xor.yaml | 142 +++++++++++++++++++ cases/arithmetic_decimal/power_decimal.yaml | 20 +++ dialects/snowflake.yaml | 12 ++ 5 files changed, 438 insertions(+) create mode 100644 cases/arithmetic_decimal/bitwise_and.yaml create mode 100644 cases/arithmetic_decimal/bitwise_or.yaml create mode 100644 cases/arithmetic_decimal/bitwise_xor.yaml diff --git a/cases/arithmetic_decimal/bitwise_and.yaml b/cases/arithmetic_decimal/bitwise_and.yaml new file mode 100644 index 0000000..7b1f7ca --- /dev/null +++ b/cases/arithmetic_decimal/bitwise_and.yaml @@ -0,0 +1,121 @@ +base_uri: https://github.com/substrait-io/substrait/blob/main/extensions/substrait/extensions/functions_arithmetic_decimal.yaml +function: bitwise_and +cases: + - group: + id: basic + description: Basic examples without any special cases + args: + - value: 0 + type: decimal<1, 0> + - value: 1 + type: decimal<1, 0> + result: + value: 0 + type: decimal<1, 0> + - group: basic + args: + - value: 127 + type: decimal<3, 0> + - value: 127 + type: decimal<3, 0> + result: + value: 127 + type: decimal<3, 0> + - group: basic + args: + - value: -127 + type: decimal<3, 0> + - value: -10 + type: decimal<2, 0> + result: + value: -128 + type: decimal<3, 0> + - group: basic + args: + - value: 31766 + type: decimal<5, 0> + - value: 900 + type: decimal<3, 0> + result: + value: 4 + type: decimal<5, 0> + - group: basic + args: + - value: -31766 + type: decimal<5, 0> + - value: 900 + type: decimal<3, 0> + result: + value: 896 + type: decimal<5, 0> + - group: basic + args: + - value: 2147483647 + type: decimal<10, 0> + - value: 1234567 + type: decimal<7, 0> + result: + value: 1234567 + type: decimal<10, 0> + - group: basic + args: + - value: 2147483647 + type: decimal<10, 0> + - value: 1234567 + type: decimal<7, 0> + result: + value: 1234567 + type: decimal<10, 0> + - group: basic + args: + - value: 9223372036854775807 + type: decimal<19, 0> + - value: 127 + type: decimal<3, 0> + result: + value: 127 + type: decimal<19, 0> + - group: basic + args: + - value: -9223372036854775807 + type: decimal<19, 0> + - value: 127 + type: decimal<3, 0> + result: + value: 1 + type: decimal<19, 0> + - group: + id: max_values + description: test with max values + args: + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + result: + value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + - group: max_values + args: + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + # 38 0s + - value: 00000000000000000000000000000000000000 + type: decimal<38, 0> + result: + value: 0 + type: decimal<38, 0> + - group: max_values + args: + # negative 38 9s + - value: -99999999999999999999999999999999999999 + type: decimal<38, 0> + # negative 38 9s + - value: -99999999999999999999999999999999999999 + type: decimal<38, 0> + result: + value: -99999999999999999999999999999999999999 + type: decimal<38, 0> diff --git a/cases/arithmetic_decimal/bitwise_or.yaml b/cases/arithmetic_decimal/bitwise_or.yaml new file mode 100644 index 0000000..e27de8e --- /dev/null +++ b/cases/arithmetic_decimal/bitwise_or.yaml @@ -0,0 +1,143 @@ +base_uri: https://github.com/substrait-io/substrait/blob/main/extensions/substrait/extensions/functions_arithmetic_decimal.yaml +function: bitwise_or +cases: + - group: + id: basic + description: Basic examples without any special cases + args: + - value: 0 + type: decimal<1, 0> + - value: 1 + type: decimal<1, 0> + result: + value: 1 + type: decimal<1, 0> + - group: basic + args: + - value: 127 + type: decimal<3, 0> + - value: 127 + type: decimal<3, 0> + result: + value: 127 + type: decimal<3, 0> + - group: basic + args: + - value: -127 + type: decimal<3, 0> + - value: -10 + type: decimal<2, 0> + result: + value: -9 + type: decimal<3, 0> + - group: basic + args: + - value: 31766 + type: decimal<5, 0> + - value: 900 + type: decimal<3, 0> + result: + value: 32662 + type: decimal<5, 0> + - group: basic + args: + - value: -31766 + type: decimal<5, 0> + - value: 900 + type: decimal<3, 0> + result: + value: -31762 + type: decimal<5, 0> + - group: basic + args: + - value: 2147483647 + type: decimal<10, 0> + - value: 123456789 + type: decimal<9, 0> + result: + value: 2147483647 + type: decimal<10, 0> + - group: basic + args: + - value: 2147483647 + type: decimal<10, 0> + - value: 123456789 + type: decimal<9, 0> + result: + value: 2147483647 + type: decimal<10, 0> + - group: basic + args: + - value: 9223372036854775807 + type: decimal<19, 0> + - value: 127 + type: decimal<3, 0> + result: + value: 9223372036854775807 + type: decimal<10, 0> + - group: basic + args: + - value: -9223372036854775807 + type: decimal<19, 0> + - value: 127 + type: decimal<3, 0> + result: + value: -9223372036854775681 + type: decimal<19, 0> + - group: + id: max_values + description: test with max values + args: + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + result: + value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + - group: max_values + args: + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + # 38 0s + - value: 00000000000000000000000000000000000000 + type: decimal<38, 0> + result: + # 38 9s + value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + - group: max_values + args: + # negative 38 9s + - value: -99999999999999999999999999999999999999 + type: decimal<38, 0> + # negative 38 9s + - value: -99999999999999999999999999999999999999 + type: decimal<38, 0> + result: + # negative 38 9s + value: -99999999999999999999999999999999999999 + type: decimal<38, 0> + - group: + id: null_values + description: test with null values + args: + - value: null + type: decimal<1, 0> + - value: 127 + type: decimal<3, 0> + result: + value: null + type: decimal<3, 0> + - group: null_values + args: + - value: null + type: decimal<1, 0> + - value: null + type: decimal<1, 0> + result: + value: null + type: decimal<1, 0> diff --git a/cases/arithmetic_decimal/bitwise_xor.yaml b/cases/arithmetic_decimal/bitwise_xor.yaml new file mode 100644 index 0000000..4a73c7e --- /dev/null +++ b/cases/arithmetic_decimal/bitwise_xor.yaml @@ -0,0 +1,142 @@ +base_uri: https://github.com/substrait-io/substrait/blob/main/extensions/substrait/extensions/functions_arithmetic_decimal.yaml +function: bitwise_xor +cases: + - group: + id: basic + description: Basic examples without any special cases + args: + - value: 0 + type: decimal<1, 0> + - value: 1 + type: decimal<1, 0> + result: + value: 1 + type: decimal<1, 0> + - group: basic + args: + - value: 127 + type: decimal<3, 0> + - value: 127 + type: decimal<3, 0> + result: + value: 0 + type: decimal<3, 0> + - group: basic + args: + - value: -127 + type: decimal<3, 0> + - value: -10 + type: decimal<2, 0> + result: + value: 119 + type: decimal<3, 0> + - group: basic + args: + - value: 31766 + type: decimal<5, 0> + - value: 900 + type: decimal<3, 0> + result: + value: 32658 + type: decimal<5, 0> + - group: basic + args: + - value: -31766 + type: decimal<5, 0> + - value: 900 + type: decimal<3, 0> + result: + value: -32658 + type: decimal<5, 0> + - group: basic + args: + - value: 2147483647 + type: decimal<10, 0> + - value: 123456789 + type: decimal<9, 0> + result: + value: 2024026858 + type: decimal<10, 0> + - group: basic + args: + - value: 2147483647 + type: decimal<10, 0> + - value: 123456789 + type: decimal<9, 0> + result: + value: 2024026858 + type: decimal<10, 0> + - group: basic + args: + - value: 9223372036854775807 + type: decimal<19, 0> + - value: 127 + type: decimal<3, 0> + result: + value: 9223372036854775680 + type: decimal<19, 0> + - group: basic + args: + - value: -9223372036854775807 + type: decimal<19, 0> + - value: 127 + type: decimal<3, 0> + result: + value: -9223372036854775682 + type: decimal<19, 0> + - group: + id: max_values + description: test with max values + args: + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + result: + value: 0 + type: decimal<38, 0> + - group: max_values + args: + # 38 9s + - value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + # 38 0s + - value: 00000000000000000000000000000000000000 + type: decimal<38, 0> + result: + # 38 9s + value: 99999999999999999999999999999999999999 + type: decimal<38, 0> + - group: max_values + args: + # negative 38 9s + - value: -99999999999999999999999999999999999999 + type: decimal<38, 0> + # negative 38 9s + - value: -99999999999999999999999999999999999999 + type: decimal<38, 0> + result: + value: 0 + type: decimal<38, 0> + - group: + id: null_values + description: test with null values + args: + - value: null + type: decimal<1, 0> + - value: 127 + type: decimal<3, 0> + result: + value: null + type: decimal<3, 0> + - group: null_values + args: + - value: null + type: decimal<1, 0> + - value: null + type: decimal<1, 0> + result: + value: null + type: decimal<1, 0> diff --git a/cases/arithmetic_decimal/power_decimal.yaml b/cases/arithmetic_decimal/power_decimal.yaml index 699a216..a71154a 100644 --- a/cases/arithmetic_decimal/power_decimal.yaml +++ b/cases/arithmetic_decimal/power_decimal.yaml @@ -92,3 +92,23 @@ cases: complex_number_result: ERROR result: special: error + - group: + id: null_values + description: test with null values + args: + - value: null + type: decimal<38, 0> + - value: 127 + type: decimal<38, 0> + result: + value: null + type: decimal<38, 0> + - group: null_values + args: + - value: null + type: decimal<38, 0> + - value: null + type: decimal<38, 0> + result: + value: null + type: decimal<38, 0> diff --git a/dialects/snowflake.yaml b/dialects/snowflake.yaml index 4141216..84c7ef0 100644 --- a/dialects/snowflake.yaml +++ b/dialects/snowflake.yaml @@ -360,3 +360,15 @@ aggregate_functions: aggregate: true supported_kernels: - bool +- name: arithmetic_decimal.bitwise_and + local_name: bitand + supported_kernels: + - dec_dec +- name: arithmetic_decimal.bitwise_or + local_name: bitor + supported_kernels: + - dec_dec +- name: arithmetic_decimal.bitwise_xor + local_name: bitxor + supported_kernels: + - dec_dec