From 83a1f510ce33708ab43a572d1d79197ff3c79c3b Mon Sep 17 00:00:00 2001 From: Sri Krishna chowdary K Date: Mon, 11 Nov 2024 18:11:07 +0530 Subject: [PATCH] chore: add tests from bft to substrait --- .../approx_count_distinct.test | 14 ++++++ tests/cases/aggregate_generic/count.test | 9 ++++ tests/cases/arithmetic/abs.test | 18 +++++++ tests/cases/arithmetic/acos.test | 8 +++ tests/cases/arithmetic/acosh.test | 12 +++++ tests/cases/arithmetic/add.test | 8 +-- tests/cases/arithmetic/asin.test | 9 ++++ tests/cases/arithmetic/asinh.test | 8 +++ tests/cases/arithmetic/atan.test | 9 ++++ tests/cases/arithmetic/atan2.test | 8 +++ tests/cases/arithmetic/atanh.test | 9 ++++ tests/cases/arithmetic/bitwise_and.test | 14 ++++++ tests/cases/arithmetic/bitwise_not.test | 14 ++++++ tests/cases/arithmetic/bitwise_or.test | 14 ++++++ tests/cases/arithmetic/bitwise_xor.test | 14 ++++++ tests/cases/arithmetic/cos.test | 9 ++++ tests/cases/arithmetic/cosh.test | 9 ++++ tests/cases/arithmetic/divide.test | 21 ++++++++ tests/cases/arithmetic/exp.test | 11 ++++ tests/cases/arithmetic/factorial.test | 11 ++++ tests/cases/arithmetic/max.test | 2 +- tests/cases/arithmetic/min.test | 18 +++++++ tests/cases/arithmetic/modulus.test | 20 ++++++++ tests/cases/arithmetic/multiply.test | 24 +++++++++ tests/cases/arithmetic/negate.test | 19 +++++++ tests/cases/arithmetic/power.test | 11 ++++ tests/cases/arithmetic/sin.test | 9 ++++ tests/cases/arithmetic/sinh.test | 9 ++++ tests/cases/arithmetic/sqrt.test | 13 +++++ tests/cases/arithmetic/subtract.test | 21 ++++++++ tests/cases/arithmetic/sum.test | 22 ++++++++ tests/cases/arithmetic/tan.test | 9 ++++ tests/cases/arithmetic/tanh.test | 9 ++++ .../cases/arithmetic_decimal/bitwise_and.test | 18 +++++++ .../cases/arithmetic_decimal/bitwise_or.test | 22 ++++++++ .../cases/arithmetic_decimal/bitwise_xor.test | 22 ++++++++ .../arithmetic_decimal/factorial_decimal.test | 17 +++++++ .../cases/arithmetic_decimal/max_decimal.test | 18 +++++++ .../cases/arithmetic_decimal/min_decimal.test | 16 ++++++ .../arithmetic_decimal/power_decimal.test | 23 +++++++++ .../arithmetic_decimal/sqrt_decimal.test | 28 +++++++++++ .../cases/arithmetic_decimal/sum_decimal.test | 16 ++++++ tests/cases/boolean/and.test | 14 ++++++ tests/cases/boolean/and_not.test | 15 ++++++ tests/cases/boolean/bool_and.test | 12 +++++ tests/cases/boolean/bool_or.test | 13 +++++ tests/cases/boolean/not.test | 9 ++++ tests/cases/boolean/or.test | 14 ++++++ tests/cases/boolean/xor.test | 14 ++++++ tests/cases/comparison/between.test | 21 ++++++++ tests/cases/comparison/coalesce.test | 16 ++++++ tests/cases/comparison/equal.test | 19 +++++++ tests/cases/comparison/gt.test | 21 ++++++++ tests/cases/comparison/gte.test | 23 +++++++++ tests/cases/comparison/is_finite.test | 10 ++++ tests/cases/comparison/is_infinite.test | 10 ++++ tests/cases/comparison/is_nan.test | 11 ++++ .../comparison/is_not_distinct_from.test | 14 ++++++ tests/cases/comparison/is_not_null.test | 10 ++++ tests/cases/comparison/is_null.test | 9 ++++ tests/cases/comparison/lt.test | 21 ++++++++ tests/cases/comparison/lte.test | 23 +++++++++ tests/cases/comparison/not_equal.test | 19 +++++++ tests/cases/comparison/nullif.test | 18 +++++++ tests/cases/datetime/add_datetime.test | 15 ++++++ tests/cases/datetime/extract.test | 34 +++++++++++++ tests/cases/datetime/gt_datetime.test | 25 ++++++++++ tests/cases/datetime/gte_datetime.test | 30 +++++++++++ tests/cases/datetime/lt_datetime.test | 2 +- tests/cases/datetime/lte_datetime.test | 30 +++++++++++ tests/cases/datetime/subtract_datetime.test | 15 ++++++ tests/cases/logarithmic/ln.test | 19 +++++++ tests/cases/logarithmic/log10.test | 19 +++++++ tests/cases/logarithmic/log2.test | 20 ++++++++ tests/cases/logarithmic/logb.test | 18 +++++++ tests/cases/rounding/ceil.test | 7 +++ tests/cases/rounding/floor.test | 7 +++ tests/cases/rounding/round.test | 13 +++++ tests/cases/string/bit_length.test | 16 ++++++ tests/cases/string/char_length.test | 16 ++++++ tests/cases/string/concat.test | 13 +++++ tests/cases/string/concat_ws.test | 9 ++++ tests/cases/string/contains.test | 14 ++++++ tests/cases/string/ends_with.test | 15 ++++++ tests/cases/string/left.test | 14 ++++++ tests/cases/string/like.test | 12 +++++ tests/cases/string/lower.test | 15 ++++++ tests/cases/string/lpad.test | 13 +++++ tests/cases/string/ltrim.test | 16 ++++++ tests/cases/string/octet_length.test | 16 ++++++ .../cases/string/regexp_count_substring.test | 33 ++++++++++++ .../cases/string/regexp_match_substring.test | 35 +++++++++++++ tests/cases/string/regexp_replace.test | 50 +++++++++++++++++++ tests/cases/string/repeat.test | 12 +++++ tests/cases/string/replace.test | 12 +++++ tests/cases/string/reverse.test | 15 ++++++ tests/cases/string/right.test | 14 ++++++ tests/cases/string/rpad.test | 13 +++++ tests/cases/string/rtrim.test | 16 ++++++ tests/cases/string/starts_with.test | 15 ++++++ tests/cases/string/substring.test | 20 ++++++++ tests/cases/string/trim.test | 16 ++++++ tests/cases/string/upper.test | 15 ++++++ 103 files changed, 1612 insertions(+), 8 deletions(-) create mode 100644 tests/cases/aggregate_approx/approx_count_distinct.test create mode 100644 tests/cases/aggregate_generic/count.test create mode 100644 tests/cases/arithmetic/abs.test create mode 100644 tests/cases/arithmetic/acos.test create mode 100644 tests/cases/arithmetic/acosh.test create mode 100644 tests/cases/arithmetic/asin.test create mode 100644 tests/cases/arithmetic/asinh.test create mode 100644 tests/cases/arithmetic/atan.test create mode 100644 tests/cases/arithmetic/atan2.test create mode 100644 tests/cases/arithmetic/atanh.test create mode 100644 tests/cases/arithmetic/bitwise_and.test create mode 100644 tests/cases/arithmetic/bitwise_not.test create mode 100644 tests/cases/arithmetic/bitwise_or.test create mode 100644 tests/cases/arithmetic/bitwise_xor.test create mode 100644 tests/cases/arithmetic/cos.test create mode 100644 tests/cases/arithmetic/cosh.test create mode 100644 tests/cases/arithmetic/divide.test create mode 100644 tests/cases/arithmetic/exp.test create mode 100644 tests/cases/arithmetic/factorial.test create mode 100644 tests/cases/arithmetic/min.test create mode 100644 tests/cases/arithmetic/modulus.test create mode 100644 tests/cases/arithmetic/multiply.test create mode 100644 tests/cases/arithmetic/negate.test create mode 100644 tests/cases/arithmetic/power.test create mode 100644 tests/cases/arithmetic/sin.test create mode 100644 tests/cases/arithmetic/sinh.test create mode 100644 tests/cases/arithmetic/sqrt.test create mode 100644 tests/cases/arithmetic/subtract.test create mode 100644 tests/cases/arithmetic/sum.test create mode 100644 tests/cases/arithmetic/tan.test create mode 100644 tests/cases/arithmetic/tanh.test create mode 100644 tests/cases/arithmetic_decimal/bitwise_and.test create mode 100644 tests/cases/arithmetic_decimal/bitwise_or.test create mode 100644 tests/cases/arithmetic_decimal/bitwise_xor.test create mode 100644 tests/cases/arithmetic_decimal/factorial_decimal.test create mode 100644 tests/cases/arithmetic_decimal/max_decimal.test create mode 100644 tests/cases/arithmetic_decimal/min_decimal.test create mode 100644 tests/cases/arithmetic_decimal/power_decimal.test create mode 100644 tests/cases/arithmetic_decimal/sqrt_decimal.test create mode 100644 tests/cases/arithmetic_decimal/sum_decimal.test create mode 100644 tests/cases/boolean/and.test create mode 100644 tests/cases/boolean/and_not.test create mode 100644 tests/cases/boolean/bool_and.test create mode 100644 tests/cases/boolean/bool_or.test create mode 100644 tests/cases/boolean/not.test create mode 100644 tests/cases/boolean/or.test create mode 100644 tests/cases/boolean/xor.test create mode 100644 tests/cases/comparison/between.test create mode 100644 tests/cases/comparison/coalesce.test create mode 100644 tests/cases/comparison/equal.test create mode 100644 tests/cases/comparison/gt.test create mode 100644 tests/cases/comparison/gte.test create mode 100644 tests/cases/comparison/is_finite.test create mode 100644 tests/cases/comparison/is_infinite.test create mode 100644 tests/cases/comparison/is_nan.test create mode 100644 tests/cases/comparison/is_not_distinct_from.test create mode 100644 tests/cases/comparison/is_not_null.test create mode 100644 tests/cases/comparison/is_null.test create mode 100644 tests/cases/comparison/lt.test create mode 100644 tests/cases/comparison/lte.test create mode 100644 tests/cases/comparison/not_equal.test create mode 100644 tests/cases/comparison/nullif.test create mode 100644 tests/cases/datetime/add_datetime.test create mode 100644 tests/cases/datetime/extract.test create mode 100644 tests/cases/datetime/gt_datetime.test create mode 100644 tests/cases/datetime/gte_datetime.test create mode 100644 tests/cases/datetime/lte_datetime.test create mode 100644 tests/cases/datetime/subtract_datetime.test create mode 100644 tests/cases/logarithmic/ln.test create mode 100644 tests/cases/logarithmic/log10.test create mode 100644 tests/cases/logarithmic/log2.test create mode 100644 tests/cases/logarithmic/logb.test create mode 100644 tests/cases/rounding/ceil.test create mode 100644 tests/cases/rounding/floor.test create mode 100644 tests/cases/rounding/round.test create mode 100644 tests/cases/string/bit_length.test create mode 100644 tests/cases/string/char_length.test create mode 100644 tests/cases/string/concat.test create mode 100644 tests/cases/string/concat_ws.test create mode 100644 tests/cases/string/contains.test create mode 100644 tests/cases/string/ends_with.test create mode 100644 tests/cases/string/left.test create mode 100644 tests/cases/string/like.test create mode 100644 tests/cases/string/lower.test create mode 100644 tests/cases/string/lpad.test create mode 100644 tests/cases/string/ltrim.test create mode 100644 tests/cases/string/octet_length.test create mode 100644 tests/cases/string/regexp_count_substring.test create mode 100644 tests/cases/string/regexp_match_substring.test create mode 100644 tests/cases/string/regexp_replace.test create mode 100644 tests/cases/string/repeat.test create mode 100644 tests/cases/string/replace.test create mode 100644 tests/cases/string/reverse.test create mode 100644 tests/cases/string/right.test create mode 100644 tests/cases/string/rpad.test create mode 100644 tests/cases/string/rtrim.test create mode 100644 tests/cases/string/starts_with.test create mode 100644 tests/cases/string/substring.test create mode 100644 tests/cases/string/trim.test create mode 100644 tests/cases/string/upper.test diff --git a/tests/cases/aggregate_approx/approx_count_distinct.test b/tests/cases/aggregate_approx/approx_count_distinct.test new file mode 100644 index 000000000..792bfa507 --- /dev/null +++ b/tests/cases/aggregate_approx/approx_count_distinct.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_aggregate_approx.yaml' + +# basic: Basic examples without any special cases +approx_count_distinct((1, -2, 3, -4, 5, 6)::i8) = 6::i64 +approx_count_distinct((-32767, -20000, 30000, 5, 32767)::i16) = 5::i64 +approx_count_distinct((-2147483648, -10000000, 30000000, 2147483647)::i32) = 4::i64 +approx_count_distinct((-214748364800000, -1000000000, 0, 922337203685477580)::i64) = 4::i64 +approx_count_distinct((1)::i8) = 1::i64 +approx_count_distinct(('abc', 'def', 'ghi')::str) = 3::i64 +approx_count_distinct(('abc', Null, 'ghi')::str) = 2::i64 +approx_count_distinct(()::i8) = 0::i64 +approx_count_distinct((Null, Null, Null)::i8) = 0::i64 +approx_count_distinct((Null, Null, 4, 3, Null, 922337203685477580, 12833888)::i64) = 4::i64 diff --git a/tests/cases/aggregate_generic/count.test b/tests/cases/aggregate_generic/count.test new file mode 100644 index 000000000..ec0f461ea --- /dev/null +++ b/tests/cases/aggregate_generic/count.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_aggregate_generic.yaml' + +# basic: Basic examples without any special cases +count((100, -200, 300, -400, 5, 6)::i16) = 6::i64 +count((1000)::i16) = 1::i64 +count(()::i16) = 0::i64 +count((Null, Null, Null)::i16) = 0::i64 +count((Null, Null, Null, 1000)::i16) = 1::i64 diff --git a/tests/cases/arithmetic/abs.test b/tests/cases/arithmetic/abs.test new file mode 100644 index 000000000..4cd6f2d80 --- /dev/null +++ b/tests/cases/arithmetic/abs.test @@ -0,0 +1,18 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +abs(25::i8) = 25::i8 +abs(-200::i16) = 200::i16 +abs(30000::i32) = 30000::i32 +abs(-9223372036854775800::i64) = 9223372036854775800::i64 +abs(2.55::fp32) = 2.55::fp32 +abs(-2.0000007152557373046875::fp64) = 2.0000007152557373046875::fp64 + +# null_input: Examples with null as input +abs(null::i8) = null::i8 + +# overflow: Examples demonstrating overflow behavior +abs(-128::i8) [overflow:ERROR] = +abs(-128::i8) [overflow:SATURATE] = 127::i8 +abs(-128::i8) [overflow:SILENT] = diff --git a/tests/cases/arithmetic/acos.test b/tests/cases/arithmetic/acos.test new file mode 100644 index 000000000..6657f9245 --- /dev/null +++ b/tests/cases/arithmetic/acos.test @@ -0,0 +1,8 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +acos(0.00::fp32) = 1.5707963267948966::fp32 +acos(1.0::fp64) = 0.0::fp64 +acos(-0.0000009::fp64) = 1.5707972267948966::fp64 +acos(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/acosh.test b/tests/cases/arithmetic/acosh.test new file mode 100644 index 000000000..90064c9d4 --- /dev/null +++ b/tests/cases/arithmetic/acosh.test @@ -0,0 +1,12 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +acosh(1.0::fp64) = 0.0::fp64 +acosh(10.0005::fp64) = 2.9932730967481995::fp64 +acosh(null::fp64) = null::fp64 + +# On_domain_error: Examples demonstrating On_domain_error behavior +acosh(0.01::fp32) [on_domain_error:ERROR] = +acosh(0.5::fp32) [on_domain_error:NAN] = nan::fp64 +acosh(0.5::fp32) [on_domain_error:NONE] = null::fp32 diff --git a/tests/cases/arithmetic/add.test b/tests/cases/arithmetic/add.test index 7d7c36a6d..cb2348b1d 100644 --- a/tests/cases/arithmetic/add.test +++ b/tests/cases/arithmetic/add.test @@ -12,12 +12,8 @@ add(120::i8, 10::i8) [overflow:ERROR] = add(30000::i16, 30000::i16) [overflow:ERROR] = add(2000000000::i32, 2000000000::i32) [overflow:ERROR] = add(9223372036854775807::i64, 1::i64) [overflow:ERROR] = - -# overflow: Examples demonstrating overflow behavior tests: overflow with SATURATE add(120::i8, 10::i8) [overflow:SATURATE] = 127::i8 add(-120::i8, -10::i8) [overflow:SATURATE] = -128::i8 - -# overflow: Examples demonstrating overflow behavior tests: overflow with SILENT add(120::i8, 10::i8) [overflow:SILENT] = # floating_exception: Examples demonstrating exceptional floating point cases @@ -25,7 +21,7 @@ add(1.5e+308::fp64, 1.5e+308::fp64) = inf::fp64 add(-1.5e+308::fp64, -1.5e+308::fp64) = -inf::fp64 # rounding: Examples demonstrating floating point rounding behavior -add(4.5::fp32, 2.500001::fp32) [rounding:TIE_TO_EVEN] = 7.000001::fp32 +add(4.5::fp32, 2.5000007152557373046875::fp32) [rounding:TIE_TO_EVEN] = 7.00000095367431640625::fp32 # types: Examples demonstrating behavior of different data types -add(4.5::fp64, 2.5000007152557373::fp64) = 7.00000071525573::fp64 +add(4.5::fp64, 2.5000007152557373046875::fp64) = 7.0000007152557373046875::fp64 diff --git a/tests/cases/arithmetic/asin.test b/tests/cases/arithmetic/asin.test new file mode 100644 index 000000000..68a3aee67 --- /dev/null +++ b/tests/cases/arithmetic/asin.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +asin(0.0::fp32) = 0.0::fp32 +asin(1.0::fp64) = 1.5707963267948966::fp64 +asin(0.009::fp64) = 0.009000121504428887::fp64 +asin(-0.009::fp64) = -0.009000121504428887::fp64 +asin(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/asinh.test b/tests/cases/arithmetic/asinh.test new file mode 100644 index 000000000..3240e8438 --- /dev/null +++ b/tests/cases/arithmetic/asinh.test @@ -0,0 +1,8 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +asinh(0.01::fp32) = 0.009999833340832886::fp32 +asinh(1.0::fp64) = 0.881373587019543::fp64 +asinh(0.0009::fp64) = 0.0008999998785000443::fp64 +asinh(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/atan.test b/tests/cases/arithmetic/atan.test new file mode 100644 index 000000000..8ed4e1fa9 --- /dev/null +++ b/tests/cases/arithmetic/atan.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +atan(0.0::fp32) = 0.0::fp32 +atan(1.0::fp64) = 0.7853981633974483::fp64 +atan(7.01::fp64) = 1.4290989925795292::fp64 +atan(-7.01::fp64) = -1.4290989925795292::fp64 +atan(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/atan2.test b/tests/cases/arithmetic/atan2.test new file mode 100644 index 000000000..95401d296 --- /dev/null +++ b/tests/cases/arithmetic/atan2.test @@ -0,0 +1,8 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +atan2(0.0::fp32, 0.0::fp32) = 0.0::fp32 +atan2(1.0::fp64, 1.0::fp64) = 0.7853981633974483::fp64 +atan2(0.009::fp64, 0.0008::fp64) = 1.482140444927459::fp64 +atan2(null::fp64, 0.0008::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/atanh.test b/tests/cases/arithmetic/atanh.test new file mode 100644 index 000000000..8d6fc94cb --- /dev/null +++ b/tests/cases/arithmetic/atanh.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +atanh(0.0::fp32) = 0.0::fp32 +atanh(1.0::fp64) = inf::fp64 +atanh(0.009::fp32) = 0.009000243011810481::fp64 +atanh(-0.009::fp32) = -0.009000243011810481::fp64 +atanh(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/bitwise_and.test b/tests/cases/arithmetic/bitwise_and.test new file mode 100644 index 000000000..222fa1b6c --- /dev/null +++ b/tests/cases/arithmetic/bitwise_and.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +bitwise_and(0::i8, 1::i8) = 0::i8 +bitwise_and(127::i8, 127::i8) = 127::i8 +bitwise_and(-127::i8, -10::i8) = -128::i8 +bitwise_and(31766::i16, 900::i16) = 4::i16 +bitwise_and(-31766::i16, 900::i16) = 896::i16 +bitwise_and(2147483647::i32, 1234567::i32) = 1234567::i32 +bitwise_and(2147483647::i32, 1234567::i32) = 1234567::i32 +bitwise_and(9223372036854775807::i64, 127::i64) = 127::i64 +bitwise_and(-9223372036854775807::i64, 127::i64) = 1::i64 +bitwise_and(null::i64, 127::i64) = null::i64 diff --git a/tests/cases/arithmetic/bitwise_not.test b/tests/cases/arithmetic/bitwise_not.test new file mode 100644 index 000000000..25a5bd943 --- /dev/null +++ b/tests/cases/arithmetic/bitwise_not.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +bitwise_not(0::i8) = -1::i8 +bitwise_not(1::i8) = -2::i8 +bitwise_not(-127::i8) = 126::i8 +bitwise_not(31766::i16) = -31767::i16 +bitwise_not(-31766::i16) = 31765::i16 +bitwise_not(2147483647::i32) = -2147483648::i32 +bitwise_not(2147483647::i32) = -2147483648::i32 +bitwise_not(9223372036854775807::i64) = -9223372036854775808::i64 +bitwise_not(-9223372036854775807::i64) = 9223372036854775806::i64 +bitwise_not(null::i64) = null::i64 diff --git a/tests/cases/arithmetic/bitwise_or.test b/tests/cases/arithmetic/bitwise_or.test new file mode 100644 index 000000000..273f7979a --- /dev/null +++ b/tests/cases/arithmetic/bitwise_or.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +bitwise_or(0::i8, 1::i8) = 1::i8 +bitwise_or(127::i8, 127::i8) = 127::i8 +bitwise_or(-127::i8, -10::i8) = -9::i8 +bitwise_or(31766::i16, 900::i16) = 32662::i16 +bitwise_or(-31766::i16, 900::i16) = -31762::i16 +bitwise_or(2147483647::i32, 123456789::i32) = 2147483647::i32 +bitwise_or(2147483647::i32, 123456789::i32) = 2147483647::i32 +bitwise_or(9223372036854775807::i64, 127::i64) = 9223372036854775807::i64 +bitwise_or(-9223372036854775807::i64, 127::i64) = -9223372036854775681::i64 +bitwise_or(null::i64, 127::i64) = null::i64 diff --git a/tests/cases/arithmetic/bitwise_xor.test b/tests/cases/arithmetic/bitwise_xor.test new file mode 100644 index 000000000..838f99f71 --- /dev/null +++ b/tests/cases/arithmetic/bitwise_xor.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +bitwise_xor(0::i8, 1::i8) = 1::i8 +bitwise_xor(127::i8, 127::i8) = 0::i8 +bitwise_xor(-127::i8, -10::i8) = 119::i8 +bitwise_xor(31766::i16, 900::i16) = 32658::i16 +bitwise_xor(-31766::i16, 900::i16) = -32658::i16 +bitwise_xor(2147483647::i32, 123456789::i32) = 2024026858::i32 +bitwise_xor(2147483647::i32, 123456789::i32) = 2024026858::i32 +bitwise_xor(9223372036854775807::i64, 127::i64) = 9223372036854775680::i64 +bitwise_xor(-9223372036854775807::i64, 127::i64) = -9223372036854775682::i64 +bitwise_xor(null::i64, 127::i64) = null::i64 diff --git a/tests/cases/arithmetic/cos.test b/tests/cases/arithmetic/cos.test new file mode 100644 index 000000000..e1d6d3b60 --- /dev/null +++ b/tests/cases/arithmetic/cos.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +cos(0.00::fp32) = 1.0::fp32 +cos(1.0::fp64) = 0.5403023058681398::fp64 +cos(7.0000009::fp64) = 0.7539016630550606::fp64 +cos(-7.00000095::fp64) = 0.7539016302056953::fp64 +cos(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/cosh.test b/tests/cases/arithmetic/cosh.test new file mode 100644 index 000000000..0a4beae13 --- /dev/null +++ b/tests/cases/arithmetic/cosh.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +cosh(0.00::fp32) = 1.0::fp32 +cosh(1.0::fp64) = 1.5430806348152437::fp64 +cosh(7.0000009::fp64) = 548.3175286399451::fp64 +cosh(-7.00000095::fp64) = 548.3175560557769::fp64 +cosh(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/divide.test b/tests/cases/arithmetic/divide.test new file mode 100644 index 000000000..3d39224dc --- /dev/null +++ b/tests/cases/arithmetic/divide.test @@ -0,0 +1,21 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +divide(25::i8, 5::i8) = 5::i8 +divide(200::i16, -100::i16) = -2::i16 +divide(60000::i32, 200::i32) = 300::i32 +divide(4000000000::i64, -5000::i64) = -800000::i64 + +# division_by_zero: Examples demonstrating division by zero +divide(5::i8, 0::i8) [on_division_by_zero:NAN] = null::i8 +divide(5::i8, 0::i8) [on_division_by_zero:ERROR] = +divide(5::i64, 0::i64) [on_division_by_zero:LIMIT] = inf::fp64 + +# overflow: Examples demonstrating overflow behavior +divide(-9223372036854775808::i64, -1::i64) [overflow:ERROR] = +divide(-128::i8, -1::i8) [overflow:SATURATE] = 127::i8 + +# floating_exception: Examples demonstrating exceptional floating point cases +divide(1.5e+208::fp64, 1.5e-200::fp64) = inf::fp64 +divide(1.5e+200::fp64, -1.5e-208::fp64) = -inf::fp64 diff --git a/tests/cases/arithmetic/exp.test b/tests/cases/arithmetic/exp.test new file mode 100644 index 000000000..ab2ddf557 --- /dev/null +++ b/tests/cases/arithmetic/exp.test @@ -0,0 +1,11 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +exp(100::i64) = 2.6881171418161356e+43::fp64 +exp(0.25::fp32) = 1.2840254166877414::fp32 +exp(0.693::fp64) = 1.9997056605411638::fp64 +exp(2.0000007152557373046875::fp64) = 7.3890613839973085::fp64 +exp(0.0::fp64) = 1.0::fp64 +exp(null::fp64) = null::fp64 +exp(1000::i64) = inf::fp64 diff --git a/tests/cases/arithmetic/factorial.test b/tests/cases/arithmetic/factorial.test new file mode 100644 index 000000000..b51345770 --- /dev/null +++ b/tests/cases/arithmetic/factorial.test @@ -0,0 +1,11 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +factorial(0::i32) = 1::i32 +factorial(1::i32) = 1::i32 +factorial(20::i64) = 2432902008176640000::i64 +factorial(null::i32) = null::i32 + +# overflow: Examples demonstrating overflow behavior +factorial(1000000::i32) [overflow:ERROR] = diff --git a/tests/cases/arithmetic/max.test b/tests/cases/arithmetic/max.test index b52959b61..2f3bc1a82 100644 --- a/tests/cases/arithmetic/max.test +++ b/tests/cases/arithmetic/max.test @@ -9,7 +9,7 @@ max((2000000000, -3217908979, 629000000, -100000000, 0, 987654321)::i64) = 20000 max((2.5, 0, 5.0, -2.5, -7.5)::fp32) = 5.0::fp32 max((1.5e+308, 1.5e+10, -1.5e+8, -1.5e+7, -1.5e+70)::fp64) = 1.5e+308::fp64 -# null_handling: Examples with null as input or output +# null_handling: Examples with null as unput or output max((Null, Null, Null)::i16) = Null::i16 max(()::i16) = Null::i16 max((2000000000, Null, 629000000, -100000000, Null, 987654321)::i64) = 2000000000::i64 diff --git a/tests/cases/arithmetic/min.test b/tests/cases/arithmetic/min.test new file mode 100644 index 000000000..132ec4b78 --- /dev/null +++ b/tests/cases/arithmetic/min.test @@ -0,0 +1,18 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +min((20, -3, 1, -10, 0, 5)::i8) = -10::i8 +min((-32768, 32767, 20000, -30000)::i16) = -32768::i16 +min((-214748648, 214748647, 21470048, 4000000)::i32) = -214748648::i32 +min((2000000000, -3217908979, 629000000, -100000000, 0, 987654321)::i64) = -3217908979::i64 +min((2.5, 0, 5.0, -2.5, -7.5)::fp32) = -7.5::fp32 +min((1.5e+308, 1.5e+10, -1.5e+8, -1.5e+7, -1.5e+70)::fp64) = -1.5e+70::fp64 +min((Null, inf)::fp64) = inf::fp64 + +# null_handling: Examples with null as unput or output +min((Null, Null, Null)::i16) = Null::i16 +min(()::i16) = Null::i16 +min((2000000000, Null, 629000000, -100000000, Null, 987654321)::i64) = -100000000::i64 +min((Null, -inf, -1.5e+8, -1.5e+7, -1.5e+70)::fp64) = -inf::fp64 +min((1.5e+308, 1.5e+10, Null, -1.5e+7, Null)::fp64) = -1.5e+7::fp64 diff --git a/tests/cases/arithmetic/modulus.test b/tests/cases/arithmetic/modulus.test new file mode 100644 index 000000000..c9ab49166 --- /dev/null +++ b/tests/cases/arithmetic/modulus.test @@ -0,0 +1,20 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +modulus(9::i8, 3::i8) = 0::i8 +modulus(10::i8, -3::i8) = 1::i8 +modulus(32767::i16, 1000::i16) = 767::i16 +modulus(-2147483647::i32, 300000000::i32) = -47483647::i32 +modulus(-9223372036854775800::i64, -80000000000000::i64) = -12036854775800::i64 +modulus(5::i8, null::i8) = null::i8 +modulus(null::i64, 1::i64) = null::i64 +modulus(null::i64, null::i64) = null::i64 + +# on_domain_error: Examples demonstrating operation when the divisor is 0 +modulus(5::i8, 0::i8) [on_domain_error:null] = null::i8 +modulus(5::i8, 0::i8) [on_domain_error:ERROR] = + +# division_type: Examples demonstrating truncate and floor division types +modulus(8::i8, -3::i8) [division_type:TRUNCATE] = 2::i8 +modulus(8::i8, -3::i8) [division_type:FLOOR] = -1::i8 diff --git a/tests/cases/arithmetic/multiply.test b/tests/cases/arithmetic/multiply.test new file mode 100644 index 000000000..56a3d23c1 --- /dev/null +++ b/tests/cases/arithmetic/multiply.test @@ -0,0 +1,24 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +multiply(25::i8, 5::i8) = 125::i8 +multiply(2::i16, -100::i16) = -200::i16 +multiply(300::i32, 200::i32) = 60000::i32 +multiply(80000::i64, -5000::i64) = -400000000::i64 + +# overflow: Examples demonstrating overflow behavior +multiply(13::i8, 10::i8) [overflow:ERROR] = +multiply(11::i16, 3000::i16) [overflow:ERROR] = +multiply(3::i32, 1000000000::i32) [overflow:ERROR] = +multiply(1000000000000000000::i64, 10::i64) [overflow:ERROR] = +multiply(13::i8, 10::i8) [overflow:SATURATE] = 127::i8 +multiply(-13::i8, -10::i8) [overflow:SATURATE] = -128::i8 +multiply(13::i8, 10::i8) [overflow:SILENT] = + +# floating_exception: Examples demonstrating exceptional floating point cases +multiply(1.5e+100::fp64, 1.5e+208::fp64) = inf::fp64 +multiply(1.5e+100::fp64, -1.5e+208::fp64) = -inf::fp64 + +# types: Examples demonstrating behavior of different data types +multiply(4.5::fp64, 2.5000007152557373046875::fp64) = 11.250003218650818::fp64 diff --git a/tests/cases/arithmetic/negate.test b/tests/cases/arithmetic/negate.test new file mode 100644 index 000000000..50aa71077 --- /dev/null +++ b/tests/cases/arithmetic/negate.test @@ -0,0 +1,19 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +negate(25::i8) = -25::i8 +negate(-200::i16) = 200::i16 +negate(30000::i32) = -30000::i32 +negate(9223372036854775800::i64) = -9223372036854775800::i64 +negate(2.50::fp32) = -2.50::fp32 +negate(2.000002861022949::fp64) = -2.000002861022949::fp64 +negate(inf::fp64) = -inf::fp64 + +# null_input: Examples with null as input +negate(null::i8) = null::i8 + +# overflow: Examples demonstrating overflow behavior +negate(-128::i8) [overflow:ERROR] = +negate(-128::i8) [overflow:SATURATE] = 127::i8 +negate(-128::i8) [overflow:SILENT] = diff --git a/tests/cases/arithmetic/power.test b/tests/cases/arithmetic/power.test new file mode 100644 index 000000000..2351c7613 --- /dev/null +++ b/tests/cases/arithmetic/power.test @@ -0,0 +1,11 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +power(8::i64, 2::i64) = 64::i64 +power(1.0::fp32, -1.0::fp32) = 1.0::fp32 +power(2.0::fp64, -2.0::fp64) = 0.25::fp64 +power(13::i64, 10::i64) = 137858491849::i64 + +# floating_exception: Examples demonstrating exceptional floating point cases +power(1.5e+100::fp64, 1.5e+208::fp64) = inf::fp64 diff --git a/tests/cases/arithmetic/sin.test b/tests/cases/arithmetic/sin.test new file mode 100644 index 000000000..c1556ac21 --- /dev/null +++ b/tests/cases/arithmetic/sin.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +sin(0.0::fp32) = 0.0::fp32 +sin(1.0::fp64) = 0.8414709848078965::fp64 +sin(7.0000009::fp64) = 0.6569872772305518::fp64 +sin(-7.0000009::fp64) = -0.6569872772305518::fp64 +sin(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/sinh.test b/tests/cases/arithmetic/sinh.test new file mode 100644 index 000000000..cb7e9d948 --- /dev/null +++ b/tests/cases/arithmetic/sinh.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +sinh(0.0::fp32) = 0.0::fp32 +sinh(1.0::fp64) = 1.1752011936438014::fp64 +sinh(7.0000009::fp64) = 548.3166167588001::fp64 +sinh(-7.0000009::fp64) = -548.3166167588001::fp64 +sinh(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/sqrt.test b/tests/cases/arithmetic/sqrt.test new file mode 100644 index 000000000..f1b90c4c3 --- /dev/null +++ b/tests/cases/arithmetic/sqrt.test @@ -0,0 +1,13 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +sqrt(25::i64) = 5::fp64 +sqrt(0::i64) = 0::fp64 +sqrt(-9223372036854775800::i64) [on_domain_error:NAN] = null::fp64 +sqrt(-9223372036854775800::i64) [on_domain_error:NAN] = null::fp64 +sqrt(-9223372036854775800::i64) [on_domain_error:NAN] = null::fp64 +sqrt(9223372036854775800::i64) = 3037000499.97605::fp64 +sqrt(null::i64) = null::fp64 +sqrt(6.25::fp32) = 2.5::fp32 +sqrt(2.0000007152557373046875::fp64) = 1.4142138152541635::fp64 diff --git a/tests/cases/arithmetic/subtract.test b/tests/cases/arithmetic/subtract.test new file mode 100644 index 000000000..b2cef3950 --- /dev/null +++ b/tests/cases/arithmetic/subtract.test @@ -0,0 +1,21 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +subtract(120::i8, 5::i8) = 115::i8 +subtract(-100::i16, 100::i16) = -200::i16 +subtract(-30000::i32, 30000::i32) = -60000::i32 +subtract(-2000000000::i64, 2000000000::i64) = -4000000000::i64 + +# overflow: Examples demonstrating overflow behavior +subtract(-120::i8, 10::i8) [overflow:ERROR] = +subtract(-30000::i16, 30000::i16) [overflow:ERROR] = +subtract(-2000000000::i32, 2000000000::i32) [overflow:ERROR] = +subtract(-9223372036854775808::i64, 1::i64) [overflow:ERROR] = +subtract(-120::i8, 10::i8) [overflow:SATURATE] = -128::i8 +subtract(120::i8, -10::i8) [overflow:SATURATE] = 127::i8 +subtract(-120::i8, 10::i8) [overflow:SILENT] = + +# floating_exception: Examples demonstrating exceptional floating point cases +subtract(-1.5e+308::fp64, 1.5e+308::fp64) = -inf::fp64 +subtract(1.5e+308::fp64, -1.5e+308::fp64) = inf::fp64 diff --git a/tests/cases/arithmetic/sum.test b/tests/cases/arithmetic/sum.test new file mode 100644 index 000000000..50f0cd6ad --- /dev/null +++ b/tests/cases/arithmetic/sum.test @@ -0,0 +1,22 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +sum((0, -1, 2, 20)::i8) = 21::i8 +sum((2000000, -3217908, 629000, -100000, 0, 987654)::i32) = 298746::i32 +sum((2.5, 0, 5.0, -2.5, -7.5)::fp32) = -2.5::fp32 +sum((2.5000007152557373046875, 7.0000007152557373046875, 0, 7.0000007152557373046875)::fp64) = 16.500002145767212::fp64 + +# overflow: Examples demonstrating overflow behavior +sum((9223372036854775806, 1, 1, 1, 1, 10000000000)::i64) [overflow:ERROR] = + +# floating_exception: Examples demonstrating exceptional floating point cases +sum((1.5e+308, 1.5e+308, 1.5e+308)::fp64) = inf::fp64 +sum((-1.5e+308, -1.5e+308, -1.5e+308)::fp64) = -inf::fp64 +sum((2.500000715, inf, 2.500000715)::fp64) = inf::fp64 +sum((2.5000007, -inf, 2.5000007, 10.0)::fp64) = -inf::fp64 + +# null_handling: Examples with null as unput or output +sum((Null, Null, Null)::i16) = Null::i16 +sum(()::i16) = Null::i16 +sum((200000, Null, 629000, -10000, 0, 987621)::i32) = 1806621::i32 diff --git a/tests/cases/arithmetic/tan.test b/tests/cases/arithmetic/tan.test new file mode 100644 index 000000000..b2a09a20b --- /dev/null +++ b/tests/cases/arithmetic/tan.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +tan(0.0::fp32) = 0.0::fp32 +tan(0.5::fp64) = 0.5463024898437905::fp64 +tan(7.01::fp64) = 0.8891974677731088::fp64 +tan(-7.01::fp64) = -0.8891974677731088::fp64 +tan(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic/tanh.test b/tests/cases/arithmetic/tanh.test new file mode 100644 index 000000000..b31e56087 --- /dev/null +++ b/tests/cases/arithmetic/tanh.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic.yaml' + +# basic: Basic examples without any special cases +tanh(0.0::fp32) = 0.0::fp32 +tanh(1.0::fp64) = 0.7615941559557649::fp64 +tanh(7.0000009::fp64) = 0.9999983369469382::fp64 +tanh(-7.0000009::fp64) = -0.9999983369469382::fp64 +tanh(null::fp64) = null::fp64 diff --git a/tests/cases/arithmetic_decimal/bitwise_and.test b/tests/cases/arithmetic_decimal/bitwise_and.test new file mode 100644 index 000000000..698e4a3be --- /dev/null +++ b/tests/cases/arithmetic_decimal/bitwise_and.test @@ -0,0 +1,18 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +bitwise_and(0::dec<1, 0>, 1::dec<1, 0>) = 0::dec<1, 0> +bitwise_and(127::dec<3, 0>, 127::dec<3, 0>) = 127::dec<3, 0> +bitwise_and(-127::dec<3, 0>, -10::dec<2, 0>) = -128::dec<3, 0> +bitwise_and(31766::dec<5, 0>, 900::dec<3, 0>) = 4::dec<5, 0> +bitwise_and(-31766::dec<5, 0>, 900::dec<3, 0>) = 896::dec<5, 0> +bitwise_and(2147483647::dec<10, 0>, 1234567::dec<7, 0>) = 1234567::dec<10, 0> +bitwise_and(-2147483647::dec<10, 0>, 1234567::dec<7, 0>) = 1::dec<10, 0> +bitwise_and(9223372036854775807::dec<19, 0>, 127::dec<3, 0>) = 127::dec<19, 0> +bitwise_and(-9223372036854775807::dec<19, 0>, 127::dec<3, 0>) = 1::dec<19, 0> + +# max_values: test with max values +bitwise_and(99999999999999999999999999999999999999::dec<38, 0>, 99999999999999999999999999999999999999::dec<38, 0>) = 99999999999999999999999999999999999999::dec<38, 0> +bitwise_and(99999999999999999999999999999999999999::dec<38, 0>, 00000000000000000000000000000000000000::dec<38, 0>) = 0::dec<38, 0> +bitwise_and(-99999999999999999999999999999999999999::dec<38, 0>, -99999999999999999999999999999999999999::dec<38, 0>) = -99999999999999999999999999999999999999::dec<38, 0> diff --git a/tests/cases/arithmetic_decimal/bitwise_or.test b/tests/cases/arithmetic_decimal/bitwise_or.test new file mode 100644 index 000000000..6af19b549 --- /dev/null +++ b/tests/cases/arithmetic_decimal/bitwise_or.test @@ -0,0 +1,22 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +bitwise_or(0::dec<1, 0>, 1::dec<1, 0>) = 1::dec<1, 0> +bitwise_or(127::dec<3, 0>, 127::dec<3, 0>) = 127::dec<3, 0> +bitwise_or(-127::dec<3, 0>, -10::dec<2, 0>) = -9::dec<3, 0> +bitwise_or(31766::dec<5, 0>, 900::dec<3, 0>) = 32662::dec<5, 0> +bitwise_or(-31766::dec<5, 0>, 900::dec<3, 0>) = -31762::dec<5, 0> +bitwise_or(2147483647::dec<10, 0>, 123456789::dec<9, 0>) = 2147483647::dec<10, 0> +bitwise_or(-2147483647::dec<10, 0>, 123456789::dec<9, 0>) = -2024026859::dec<10, 0> +bitwise_or(9223372036854775807::dec<19, 0>, 127::dec<3, 0>) = 9223372036854775807::dec<10, 0> +bitwise_or(-9223372036854775807::dec<19, 0>, 127::dec<3, 0>) = -9223372036854775681::dec<19, 0> + +# max_values: test with max values +bitwise_or(99999999999999999999999999999999999999::dec<38, 0>, 99999999999999999999999999999999999999::dec<38, 0>) = 99999999999999999999999999999999999999::dec<38, 0> +bitwise_or(99999999999999999999999999999999999999::dec<38, 0>, 00000000000000000000000000000000000000::dec<38, 0>) = 99999999999999999999999999999999999999::dec<38, 0> +bitwise_or(-99999999999999999999999999999999999999::dec<38, 0>, -99999999999999999999999999999999999999::dec<38, 0>) = -99999999999999999999999999999999999999::dec<38, 0> + +# null_values: test with null values +bitwise_or(null::dec<1, 0>, 127::dec<3, 0>) = null::dec<3, 0> +bitwise_or(null::dec<1, 0>, null::dec<1, 0>) = null::dec<1, 0> diff --git a/tests/cases/arithmetic_decimal/bitwise_xor.test b/tests/cases/arithmetic_decimal/bitwise_xor.test new file mode 100644 index 000000000..34fe790c9 --- /dev/null +++ b/tests/cases/arithmetic_decimal/bitwise_xor.test @@ -0,0 +1,22 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +bitwise_xor(0::dec<1, 0>, 1::dec<1, 0>) = 1::dec<1, 0> +bitwise_xor(127::dec<3, 0>, 127::dec<3, 0>) = 0::dec<3, 0> +bitwise_xor(-127::dec<3, 0>, -10::dec<2, 0>) = 119::dec<3, 0> +bitwise_xor(31766::dec<5, 0>, 900::dec<3, 0>) = 32658::dec<5, 0> +bitwise_xor(-31766::dec<5, 0>, 900::dec<3, 0>) = -32658::dec<5, 0> +bitwise_xor(2147483647::dec<10, 0>, 123456789::dec<9, 0>) = 2024026858::dec<10, 0> +bitwise_xor(-2147483647::dec<10, 0>, 123456789::dec<9, 0>) = -2024026860::dec<10, 0> +bitwise_xor(9223372036854775807::dec<19, 0>, 127::dec<3, 0>) = 9223372036854775680::dec<19, 0> +bitwise_xor(-9223372036854775807::dec<19, 0>, 127::dec<3, 0>) = -9223372036854775682::dec<19, 0> + +# max_values: test with max values +bitwise_xor(99999999999999999999999999999999999999::dec<38, 0>, 99999999999999999999999999999999999999::dec<38, 0>) = 0::dec<38, 0> +bitwise_xor(99999999999999999999999999999999999999::dec<38, 0>, 00000000000000000000000000000000000000::dec<38, 0>) = 99999999999999999999999999999999999999::dec<38, 0> +bitwise_xor(-99999999999999999999999999999999999999::dec<38, 0>, -99999999999999999999999999999999999999::dec<38, 0>) = 0::dec<38, 0> + +# null_values: test with null values +bitwise_xor(null::dec<1, 0>, 127::dec<3, 0>) = null::dec<3, 0> +bitwise_xor(null::dec<1, 0>, null::dec<1, 0>) = null::dec<1, 0> diff --git a/tests/cases/arithmetic_decimal/factorial_decimal.test b/tests/cases/arithmetic_decimal/factorial_decimal.test new file mode 100644 index 000000000..19fc1d3d3 --- /dev/null +++ b/tests/cases/arithmetic_decimal/factorial_decimal.test @@ -0,0 +1,17 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +factorial(0::dec<1,0>) = 1::dec<38,0> +factorial(1::dec<1,0>) = 1::dec<38,0> +factorial(20::dec<2,0>) = 2432902008176640000::dec<38,0> + +# overflow: Examples demonstrating overflow behavior +factorial(34::dec<2,0>) = + +# negative_value: Examples demonstrating behavior on negative value +factorial(-1::dec<1,0>) = + +# null_values: test with null values +factorial(null::dec<38, 0>) = null::dec<38, 0> +factorial(null::dec<1, 0>) = null::dec<38, 0> diff --git a/tests/cases/arithmetic_decimal/max_decimal.test b/tests/cases/arithmetic_decimal/max_decimal.test new file mode 100644 index 000000000..86be47a34 --- /dev/null +++ b/tests/cases/arithmetic_decimal/max_decimal.test @@ -0,0 +1,18 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +max((20, -3, 1, -10, 0, 5)::dec<2, 0>) = 20::dec<2, 0> +max((-32768, 32767, 20000, -30000)::dec<5, 0>) = 32767::dec<5, 0> +max((-214748648, 214748647, 21470048, 4000000)::dec<9, 0>) = 214748647::dec<9, 0> +max((2000000000, -3217908979, 629000000, -100000000, 0, 987654321)::dec<10, 0>) = 2000000000::dec<10, 0> +max((2.5, 0, 5.0, -2.5, -7.5)::dec<2, 1>) = 5.0::dec<2, 1> +max((99999999999999999999999999999999999999, 0, -99999999999999999999999999999999999998, 111111111, -76)::dec<38, 0>) = 99999999999999999999999999999999999999::dec<38, 0> + +# null_handling: Examples with null as unput or output +max((Null, Null, Null)::dec<1, 0>) = Null::dec<1, 0> +max(()::dec<1, 0>) = Null::dec<1, 0> +max((2000000000, Null, 629000000, -100000000, Null, 987654321)::dec<10, 0>) = 2000000000::dec<10, 0> +max((Null, Null)::dec<1, 0>) = Null::dec<1, 0> +max(()::dec<1, 0>) = Null::dec<1, 0> +max((99999999999999999999999999999999999999, -99999999999999999999999999999999999998, Null, 11111111111111111111111111111111111111, Null)::dec<38, 0>) = 99999999999999999999999999999999999999::dec<38, 0> diff --git a/tests/cases/arithmetic_decimal/min_decimal.test b/tests/cases/arithmetic_decimal/min_decimal.test new file mode 100644 index 000000000..bbbdd508a --- /dev/null +++ b/tests/cases/arithmetic_decimal/min_decimal.test @@ -0,0 +1,16 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +min((20, -3, 1, -10, 0, 5)::dec<2, 0>) = -10::dec<2, 0> +min((-32768, 32767, 20000, -30000)::dec<5, 0>) = -32768::dec<5, 0> +min((-214748648, 214748647, 21470048, 4000000)::dec<9, 0>) = -214748648::dec<9, 0> +min((2000000000, -3217908979, 629000000, -100000000, 0, 987654321)::dec<10, 0>) = -3217908979::dec<10, 0> +min((2.5, 0, 5.0, -2.5, -7.5)::dec<2, 1>) = -7.5::dec<2, 1> +min((99999999999999999999999999999999999999, -99999999999999999999999999999999999998, -99999999999999999999999999999999999997, 0, 1111)::dec<38, 0>) = -99999999999999999999999999999999999998::dec<38, 0> + +# null_handling: Examples with null as unput or output +min((Null, Null, Null)::dec<1, 0>) = Null::dec<1, 0> +min(()::dec<1, 0>) = Null::dec<1, 0> +min((2000000000, Null, 629000000, -100000000, Null, 987654321)::dec<10, 0>) = -100000000::dec<10, 0> +min((-99999999999999999999999999999999999998, Null, 99999999999999999999999999999999999999, Null)::dec<38, 0>) = -99999999999999999999999999999999999998::dec<38, 0> diff --git a/tests/cases/arithmetic_decimal/power_decimal.test b/tests/cases/arithmetic_decimal/power_decimal.test new file mode 100644 index 000000000..386638335 --- /dev/null +++ b/tests/cases/arithmetic_decimal/power_decimal.test @@ -0,0 +1,23 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +power(8::dec, 2::dec<38, 0>) = 64::fp64 +power(1.0::dec, -1.0::dec<38, 0>) = 1.0::fp64 +power(2.0::dec<38, 0>, -2.0::dec<38, 0>) = 0.25::fp64 +power(13::dec<38, 0>, 10::dec<38, 0>) = 137858491849::fp64 + +# result_more_than_input_precison: Examples demonstrating result with more precision than input +power(16::dec<2, 0>, 4::dec<38, 0>) = 65536::fp64 + +# floating_exception: Examples demonstrating exceptional floating point cases +power(1.5e+10::dec<38, 0>, 1.5e+20::dec<38, 0>) = inf::fp64 +power(-16::dec<4, 0>, 1001::dec<4, 0>) = -inf::fp64 + +# complex_number: Examples demonstrating complex number output +power(-1::dec, 0.5::dec<38,1>) [complex_number_result:NAN] = nan::fp64 +power(-1::dec, 0.5::dec<38,1>) [complex_number_result:ERROR] = + +# null_values: test with null values +power(null::dec<38, 0>, 127::dec<38, 0>) = null::dec<38, 0> +power(null::dec<38, 0>, null::dec<38, 0>) = null::dec<38, 0> diff --git a/tests/cases/arithmetic_decimal/sqrt_decimal.test b/tests/cases/arithmetic_decimal/sqrt_decimal.test new file mode 100644 index 000000000..a0c0dae0b --- /dev/null +++ b/tests/cases/arithmetic_decimal/sqrt_decimal.test @@ -0,0 +1,28 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +sqrt(25::dec<2,0>) = 5::fp64 +sqrt(0::dec<1,0>) = 0::fp64 + +# max_input: max allowed input returns correct result +sqrt(99999999999999999999999999999999999999::dec<38,0>) = 1e+19::fp64 + +# real_number: real number as input +sqrt(6.25::dec<3,2>) = 2.5::fp64 +sqrt(2.0000007152557373046875::dec<23,22>) = 1.4142138152541635::fp64 + +# verify_real_number: verify real number operation are different and doesn't behave as nearby int +sqrt(9::dec<1,0>) = 3::fp64 +sqrt(8.3::dec<2,1>) = 2.8809720581775866::fp64 +sqrt(8.5::dec<2,1>) = 2.9154759474226504::fp64 +sqrt(8.7::dec<2,1>) = 2.949576240750525::fp64 +sqrt(9.2::dec<2,1>) = 3.03315017762062::fp64 + +# negative_input: negative input returns error +sqrt(-9223372036854775800::dec<19,0>) = +sqrt(-2.5::dec<2,1>) = + +# null_values: test with null values +sqrt(null::dec<38, 0>) = null::fp64 +sqrt(null::dec<1, 0>) = null::fp64 diff --git a/tests/cases/arithmetic_decimal/sum_decimal.test b/tests/cases/arithmetic_decimal/sum_decimal.test new file mode 100644 index 000000000..af2eae936 --- /dev/null +++ b/tests/cases/arithmetic_decimal/sum_decimal.test @@ -0,0 +1,16 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_arithmetic_decimal.yaml' + +# basic: Basic examples without any special cases +sum((0, -1, 2, 20)::dec<2, 0>) = 21::dec<38, 0> +sum((2000000, -3217908, 629000, -100000, 0, 987654)::dec<7, 0>) = 298746::dec<38, 0> +sum((2.5, 0, 5.0, -2.5, -7.5)::dec<2, 1>) = -2.5::dec<38, 2> +sum((2.5000007152557373046875, 7.0000007152557373046875, 0, 7.0000007152557373046875)::dec<23, 22>) = 16.5000021457672119140625::dec<38, 22> + +# overflow: Examples demonstrating overflow behavior +sum((99999999999999999999999999999999999999, 1, 1, 1, 1, 99999999999999999999999999999999999999)::dec<38, 0>) [overflow:ERROR] = + +# null_handling: Examples with null as unput or output +sum((Null, Null, Null)::dec<1, 0>) = Null::dec<38, 0> +sum(()::dec<1, 0>) = Null::dec<38, 0> +sum((200000, Null, 629000, -10000, 0, 987621)::dec<6, 0>) = 1806621::dec<38, 0> diff --git a/tests/cases/boolean/and.test b/tests/cases/boolean/and.test new file mode 100644 index 000000000..8580c3a42 --- /dev/null +++ b/tests/cases/boolean/and.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_boolean.yaml' + +# basic: Basic examples without any special cases +and(true::bool, true::bool) = true::bool +and(true::bool, false::bool) = false::bool +and(false::bool, false::bool) = false::bool + +# null_input: Examples with null as input +and(true::bool, null::bool) = null::bool +and(null::bool, true::bool) = null::bool +and(false::bool, null::bool) = false::bool +and(null::bool, false::bool) = false::bool +and(null::bool, null::bool) = null::bool diff --git a/tests/cases/boolean/and_not.test b/tests/cases/boolean/and_not.test new file mode 100644 index 000000000..daf6ce8e0 --- /dev/null +++ b/tests/cases/boolean/and_not.test @@ -0,0 +1,15 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_boolean.yaml' + +# basic: Basic examples without any special cases +and_not(true::bool, false::bool) = true::bool +and_not(true::bool, true::bool) = false::bool +and_not(false::bool, true::bool) = false::bool +and_not(false::bool, false::bool) = false::bool + +# null_input: Examples with null as input +and_not(true::bool, null::bool) = null::bool +and_not(null::bool, false::bool) = null::bool +and_not(false::bool, null::bool) = false::bool +and_not(null::bool, true::bool) = false::bool +and_not(null::bool, null::bool) = null::bool diff --git a/tests/cases/boolean/bool_and.test b/tests/cases/boolean/bool_and.test new file mode 100644 index 000000000..5297cbbd1 --- /dev/null +++ b/tests/cases/boolean/bool_and.test @@ -0,0 +1,12 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_boolean.yaml' + +# basic: Basic examples without any special cases +bool_and((true, true)::bool) = true::bool +bool_and((true, false)::bool) = false::bool +bool_and((false, false)::bool) = false::bool +bool_and((true)::bool) = true::bool +bool_and((true, null)::bool) = true::bool +bool_and((null, null)::bool) = null::bool +bool_and((false, null)::bool) = false::bool +bool_and(()::bool) = null::bool diff --git a/tests/cases/boolean/bool_or.test b/tests/cases/boolean/bool_or.test new file mode 100644 index 000000000..16688ef54 --- /dev/null +++ b/tests/cases/boolean/bool_or.test @@ -0,0 +1,13 @@ +### SUBSTRAIT_AGGREGATE_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_boolean.yaml' + +# basic: Basic examples without any special cases +bool_or((true, true)::bool) = true::bool +bool_or((false, false)::bool) = false::bool +bool_or((true, false)::bool) = true::bool +bool_or((false)::bool) = false::bool +bool_or((true)::bool) = true::bool +bool_or((true, null)::bool) = true::bool +bool_or((null, null)::bool) = null::bool +bool_or((false, null)::bool) = false::bool +bool_or(()::bool) = null::bool diff --git a/tests/cases/boolean/not.test b/tests/cases/boolean/not.test new file mode 100644 index 000000000..6aac5142a --- /dev/null +++ b/tests/cases/boolean/not.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_boolean.yaml' + +# basic: Basic examples without any special cases +not(true::bool) = false::bool +not(false::bool) = true::bool + +# null_input: Examples with null as input +not(null::bool) = null::bool diff --git a/tests/cases/boolean/or.test b/tests/cases/boolean/or.test new file mode 100644 index 000000000..786e39860 --- /dev/null +++ b/tests/cases/boolean/or.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_boolean.yaml' + +# basic: Basic examples without any special cases +or(true::bool, true::bool) = true::bool +or(true::bool, false::bool) = true::bool +or(false::bool, false::bool) = false::bool + +# null_input: Examples with null as input +or(true::bool, null::bool) = true::bool +or(null::bool, true::bool) = true::bool +or(false::bool, null::bool) = null::bool +or(null::bool, false::bool) = null::bool +or(null::bool, null::bool) = null::bool diff --git a/tests/cases/boolean/xor.test b/tests/cases/boolean/xor.test new file mode 100644 index 000000000..1a4d1643f --- /dev/null +++ b/tests/cases/boolean/xor.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_boolean.yaml' + +# basic: Basic examples without any special cases +xor(true::bool, false::bool) = true::bool +xor(true::bool, true::bool) = false::bool +xor(false::bool, false::bool) = false::bool +xor(false::bool, true::bool) = true::bool + +# null_input: Examples with null as input +xor(true::bool, null::bool) = null::bool +xor(null::bool, true::bool) = null::bool +xor(false::bool, null::bool) = null::bool +xor(null::bool, false::bool) = null::bool diff --git a/tests/cases/comparison/between.test b/tests/cases/comparison/between.test new file mode 100644 index 000000000..d4f34c124 --- /dev/null +++ b/tests/cases/comparison/between.test @@ -0,0 +1,21 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +between(5::i8, 0::i8, 127::i8) = true::bool +between(20000::i16, 1::i16, 30000::i16) = true::bool +between(1030000000::i32, 1000000000::i32, 2000000000::i32) = true::bool +between(10300000000900::i64, 1000000000::i64, 9223372036854775807::i64) = true::bool +between(2::i8, 1::i8, -120::i8) = False::bool +between(-10000::i16, -20000::i16, -30000::i16) = False::bool +between(-100000000::i32, -1000000000::i32, -2000000000::i32) = False::bool +between(92233720368547758::i64, 1::i64, -9223372036854775807::i64) = False::bool +between(14.01::fp32, 20.90::fp32, 88.00::fp32) = False::bool +between(14.011::fp64, 0.00::fp64, inf::fp64) = True::bool +between(inf::fp64, 0.00::fp64, 100.09::fp64) = False::bool +between(-100.0011::fp64, -inf::fp64, 0.00::fp64) = True::bool + +# null_input: Examples with null as input +between(null::i8, 1::i8, 10::i8) = null::bool +between(1::i64, null::i64, 10::i64) = null::bool +between(1::i64, 1::i64, null::i64) = null::bool diff --git a/tests/cases/comparison/coalesce.test b/tests/cases/comparison/coalesce.test new file mode 100644 index 000000000..aa869b9f5 --- /dev/null +++ b/tests/cases/comparison/coalesce.test @@ -0,0 +1,16 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +coalesce(1::i8, 2::i8) = 1::i8 +coalesce(null::i8, 2::i8) = 2::i8 +coalesce(null::i16, null::i16) = null::i16 +coalesce(2000000::i32, null::i32) = 2000000::i32 +coalesce(null::i64, 9223372036854775807::i64) = 9223372036854775807::i64 +coalesce(null::fp32, -65.500000::fp32) = -65.500000::fp32 +coalesce(inf::fp64, -inf::fp64) = inf::fp64 +coalesce(7::dec<38, 0>, 4::dec<38, 0>) = 7::dec<38, 0> +coalesce(null::dec<38, 0>, 2::dec<38, 0>) = 2::dec<38, 0> +coalesce(null::dec<38, 0>, null::dec<38, 0>) = null::dec<38, 0> +coalesce(2000000::dec<38, 0>, null::dec<38, 0>) = 2000000::dec<38, 0> +coalesce(null::dec<38, 0>, 2000000::dec<38, 0>) = 2000000::dec<38, 0> diff --git a/tests/cases/comparison/equal.test b/tests/cases/comparison/equal.test new file mode 100644 index 000000000..470bf76ac --- /dev/null +++ b/tests/cases/comparison/equal.test @@ -0,0 +1,19 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +equal(1::i8, 1::i8) = true::bool +equal(300::i16, 200::i16) = false::bool +equal(-2147483648::i32, -2147483648::i32) = true::bool +equal(9223372036854775807::i64, 9223372036854775804::i64) = false::bool +equal(inf::fp64, inf::fp64) = true::bool +equal(inf::fp64, 1.5e+308::fp64) = false::bool +equal(10::dec<38, 0>, 10::dec<38, 0>) = true::bool +equal(10::dec<38, 0>, 11.25::dec<38, 2>) = false::bool +equal(inf::fp64, -inf::fp64) = false::bool + +# null_input: Examples with null as input +equal(null::i16, 1::i16) = null::bool +equal(null::i16, null::i16) = null::bool +equal(7::dec<38, 0>, null::dec<38, 0>) = null::bool +equal(null::dec<38, 0>, null::dec<38, 0>) = null::bool diff --git a/tests/cases/comparison/gt.test b/tests/cases/comparison/gt.test new file mode 100644 index 000000000..946fbf9da --- /dev/null +++ b/tests/cases/comparison/gt.test @@ -0,0 +1,21 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +gt(1::i8, 2::i8) = false::bool +gt(200::i16, 199::i16) = true::bool +gt(200::i16, 200::i16) = false::bool +gt(2000000000::i32, 1000000000::i32) = true::bool +gt(-922337203685775808::i64, -922337203685775807::i64) = false::bool +gt(7.25::fp32, 2.50::fp32) = true::bool +gt(-922337203685775808::dec<38, 0>, -922337203685775807::dec<38, 0>) = false::bool +gt(7.25::dec<38, 2>, 2.50::dec<38, 2>) = true::bool +gt(-1.5e+308::fp64, -inf::fp64) = true::bool +gt(null::i16, 100::i16) = null::bool + +# null_input: Examples with null as input +gt(inf::fp64, 1.5e+308::fp64) = true::bool +gt(2::i16, null::i16) = null::bool +gt(null::i16, null::i16) = null::bool +gt(2::dec<38, 2>, null::dec<38, 2>) = null::bool +gt(null::dec<38, 2>, null::dec<38, 2>) = null::bool diff --git a/tests/cases/comparison/gte.test b/tests/cases/comparison/gte.test new file mode 100644 index 000000000..a11522e00 --- /dev/null +++ b/tests/cases/comparison/gte.test @@ -0,0 +1,23 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +gte(1::i8, 2::i8) = false::bool +gte(2::i8, 2::i8) = true::bool +gte(200::i16, 199::i16) = true::bool +gte(2000000000::i32, 1000000000::i32) = true::bool +gte(-922337203685775808::i64, -922337203685775807::i64) = false::bool +gte(7.25::fp32, 2.50::fp32) = true::bool +gte(7.25::fp32, 7.25::fp32) = true::bool +gte(7.25::dec<38, 2>, 7.25::dec<38, 2>) = true::bool +gte(7.25::dec<38, 2>, 7.27::dec<38, 2>) = false::bool +gte(inf::fp64, 1.5e+308::fp64) = true::bool +gte(inf::fp64, inf::fp64) = true::bool +gte(-inf::fp64, -1.5e+308::fp64) = false::bool +gte(null::dec<38, 2>, 7.25::dec<38, 2>) = null::bool +gte(null::dec<38, 2>, null::dec<38, 2>) = null::bool + +# null_input: Examples with null as input +gte(null::i16, 1::i16) = null::bool +gte(2::i16, null::i16) = null::bool +gte(null::i16, null::i16) = null::bool diff --git a/tests/cases/comparison/is_finite.test b/tests/cases/comparison/is_finite.test new file mode 100644 index 000000000..cf1a8d5e8 --- /dev/null +++ b/tests/cases/comparison/is_finite.test @@ -0,0 +1,10 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +is_finite(0.0::fp32) = true::bool +is_finite(0.55::fp32) = true::bool +is_finite(1000.000000000001::fp64) = true::bool +is_finite(-inf::fp64) = false::bool +is_finite(inf::fp64) = false::bool +is_finite(null::fp64) = null::bool diff --git a/tests/cases/comparison/is_infinite.test b/tests/cases/comparison/is_infinite.test new file mode 100644 index 000000000..565f8a7ac --- /dev/null +++ b/tests/cases/comparison/is_infinite.test @@ -0,0 +1,10 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +is_infinite(0.0::fp32) = false::bool +is_infinite(0.55::fp32) = false::bool +is_infinite(1000.000000000001::fp64) = false::bool +is_infinite(-inf::fp64) = true::bool +is_infinite(inf::fp64) = true::bool +is_infinite(null::fp64) = null::bool diff --git a/tests/cases/comparison/is_nan.test b/tests/cases/comparison/is_nan.test new file mode 100644 index 000000000..afe318a87 --- /dev/null +++ b/tests/cases/comparison/is_nan.test @@ -0,0 +1,11 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +is_nan(0.0::fp32) = false::bool +is_nan(0.55::fp32) = false::bool +is_nan(1000.000000000001::fp64) = false::bool +is_nan(-inf::fp64) = false::bool +is_nan(inf::fp64) = false::bool +is_nan(null::fp64) = null::bool +is_nan(nan::fp64) = true::bool diff --git a/tests/cases/comparison/is_not_distinct_from.test b/tests/cases/comparison/is_not_distinct_from.test new file mode 100644 index 000000000..b10395c09 --- /dev/null +++ b/tests/cases/comparison/is_not_distinct_from.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +is_not_distinct_from(1::i16, 1::i16) = true::bool +is_not_distinct_from(2::i16, 1::i16) = false::bool +is_not_distinct_from(1.75::dec<38, 2>, 1.75::dec<38, 2>) = true::bool +is_not_distinct_from(1.75::dec<38, 2>, 1.1::dec<38, 2>) = false::bool + +# null_input: Examples with null as input +is_not_distinct_from(null::i16, 1::i16) = false::bool +is_not_distinct_from(null::i16, null::i16) = true::bool +is_not_distinct_from(10::dec<38, 0>, null::dec<38, 0>) = false::bool +is_not_distinct_from(null::dec<38, 0>, null::dec<38, 0>) = true::bool diff --git a/tests/cases/comparison/is_not_null.test b/tests/cases/comparison/is_not_null.test new file mode 100644 index 000000000..0ddc8b025 --- /dev/null +++ b/tests/cases/comparison/is_not_null.test @@ -0,0 +1,10 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +is_not_null(25::i16) = true::bool +is_not_null(true::bool) = true::bool +is_not_null(7.25::fp32) = true::bool +is_not_null(7.25::dec<38, 3>) = true::bool +is_not_null(null::i8) = False::bool +is_not_null(null::dec<38, 3>) = false::bool diff --git a/tests/cases/comparison/is_null.test b/tests/cases/comparison/is_null.test new file mode 100644 index 000000000..5adc948c2 --- /dev/null +++ b/tests/cases/comparison/is_null.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +is_null(25::i16) = false::bool +is_null(false::bool) = false::bool +is_null(7.823::dec<38, 3>) = false::bool +is_null(null::i16) = true::bool +is_null(null::dec<38, 3>) = true::bool diff --git a/tests/cases/comparison/lt.test b/tests/cases/comparison/lt.test new file mode 100644 index 000000000..8496fdd6a --- /dev/null +++ b/tests/cases/comparison/lt.test @@ -0,0 +1,21 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +lt(1::i8, 2::i8) = true::bool +lt(200::i16, 100::i16) = false::bool +lt(1000::i16, 1000::i16) = false::bool +lt(2000000000::i32, 1000000000::i32) = false::bool +lt(-922337203685775808::i64, -922337203685775807::i64) = true::bool +lt(7.25::fp32, 2.50::fp32) = false::bool +lt(7.25::dec<38, 2>, 7.25::dec<38, 2>) = false::bool +lt(2.49::dec<38, 2>, 2.50::dec<38, 2>) = true::bool +lt(1.5e+308::fp64, inf::fp64) = true::bool +lt(-1.5e+308::fp64, -inf::fp64) = false::bool +lt(null::dec<38, 2>, 2.50::dec<38, 2>) = null::bool +lt(null::dec<38, 2>, null::dec<38, 2>) = null::bool + +# null_input: Examples with null as input +lt(null::i16, 1::i16) = null::bool +lt(2::i16, null::i16) = null::bool +lt(null::i16, null::i16) = null::bool diff --git a/tests/cases/comparison/lte.test b/tests/cases/comparison/lte.test new file mode 100644 index 000000000..294a9d45f --- /dev/null +++ b/tests/cases/comparison/lte.test @@ -0,0 +1,23 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +lte(1::i8, 2::i8) = true::bool +lte(2::i8, 2::i8) = true::bool +lte(200::i16, 199::i16) = false::bool +lte(2000000000::i32, 1000000000::i32) = false::bool +lte(-922337203685775808::i64, -922337203685775807::i64) = true::bool +lte(7.00::fp32, 2.50::fp32) = false::bool +lte(7.25::fp32, 7.25::fp32) = true::bool +lte(7.25::dec<38, 2>, 7.25::dec<38, 2>) = true::bool +lte(2.59::dec<38, 2>, 2.50::dec<38, 2>) = false::bool +lte(1.5e+308::fp64, inf::fp64) = true::bool +lte(inf::fp64, inf::fp64) = true::bool +lte(-1.5e+308::fp64, -inf::fp64) = false::bool +lte(null::dec<38, 2>, 2.50::dec<38, 2>) = null::bool +lte(null::dec<38, 2>, null::dec<38, 2>) = null::bool + +# null_input: Examples with null as input +lte(null::i16, 1::i16) = null::bool +lte(2::i16, null::i16) = null::bool +lte(null::i16, null::i16) = null::bool diff --git a/tests/cases/comparison/not_equal.test b/tests/cases/comparison/not_equal.test new file mode 100644 index 000000000..4bb927110 --- /dev/null +++ b/tests/cases/comparison/not_equal.test @@ -0,0 +1,19 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +not_equal(1::i8, 1::i8) = false::bool +not_equal(300::i16, 200::i16) = true::bool +not_equal(-2147483648::i32, -2147483648::i32) = false::bool +not_equal(9223372036854775807::i64, 9223372036854775804::i64) = true::bool +not_equal(9223372036854775807::dec<38, 0>, 9223372036854775804::dec<38, 0>) = true::bool +not_equal(9223372036854775804::dec<38, 0>, 9223372036854775804::dec<38, 0>) = false::bool +not_equal(inf::fp64, inf::fp64) = false::bool +not_equal(inf::fp64, 1.5e+308::fp64) = true::bool +not_equal(inf::fp64, -inf::fp64) = true::bool +not_equal(null::dec<38, 2>, 2.50::dec<38, 2>) = null::bool +not_equal(null::dec<38, 2>, null::dec<38, 2>) = null::bool + +# null_input: Examples with null as input +not_equal(null::i16, 1::i16) = null::bool +not_equal(null::i16, null::i16) = null::bool diff --git a/tests/cases/comparison/nullif.test b/tests/cases/comparison/nullif.test new file mode 100644 index 000000000..eb325ac80 --- /dev/null +++ b/tests/cases/comparison/nullif.test @@ -0,0 +1,18 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_comparison.yaml' + +# basic: Basic examples without any special cases +nullif(1::i16, 5::i16) = 1::i16 +nullif(7.25::fp32, 1.00::fp32) = 7.25::fp32 +nullif(1.11::fp32, 1.11::fp32) = null::fp32 +nullif(false::bool, true::bool) = false::bool +nullif(true::bool, false::bool) = true::bool +nullif(false::bool, false::bool) = null::bool +nullif(true::bool, true::bool) = null::bool + +# null_input: Examples with null as input +nullif(null::bool, true::bool) = null::bool +nullif(true::bool, null::bool) = true::bool +nullif(null::bool, null::bool) = null::bool +nullif(10::dec<38, 0>, null::dec<38, 0>) = 10::dec<38, 0> +nullif(null::dec<38, 0>, null::dec<38, 0>) = null::bool diff --git a/tests/cases/datetime/add_datetime.test b/tests/cases/datetime/add_datetime.test new file mode 100644 index 000000000..92694d49b --- /dev/null +++ b/tests/cases/datetime/add_datetime.test @@ -0,0 +1,15 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_datetime.yaml' + +# timestamps: examples using the timestamp types +add('2016-12-31T13:30:15'::ts, 'P5D'::iday) = '2017-01-05T13:30:15'::ts +add('2016-12-01T13:30:15'::ts, 'P5Y'::iyear) = '2021-12-01T13:30:15'::ts +add('2016-12-01T13:30:15'::ts, 'PT5H'::iday) = '2016-12-01T18:30:15'::ts + +# date_to_timestamp: examples using the date types and resulting in a timestamp +add('2020-12-31'::date, 'P5D'::iday) = '2021-01-05T00:00:00'::ts +add('2020-12-31'::date, 'P5Y'::iyear) = '2025-12-31T00:00:00'::ts +add('2020-12-31'::date, 'P5M'::iyear) = '2021-05-31T00:00:00'::ts + +# null_input: examples with null args or return +add(null::date, 'P5D'::iday) = null::date diff --git a/tests/cases/datetime/extract.test b/tests/cases/datetime/extract.test new file mode 100644 index 000000000..c78a7966b --- /dev/null +++ b/tests/cases/datetime/extract.test @@ -0,0 +1,34 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_datetime.yaml' + +# timestamps: examples using the timestamp and timestamptz types +extract('YEAR'::str, '2016-12-31T13:30:15'::ts) = 2016::i64 +extract('ISOYEAR'::str, '2016-01-01T13:30:15'::ts) = 2015::i64 +extract('QUARTER'::str, '2016-12-31T13:30:15'::ts) = 4::i64 +extract('MONTH'::str, '2016-12-31T13:30:15'::ts) = 12::i64 +extract('WEEK'::str, '2016-12-31T13:30:15'::ts) = 52::i64 +extract('DAY'::str, '2016-12-31T13:30:15'::ts) = 31::i64 +extract('ISODOW'::str, '2016-12-25T13:30:15'::ts) = 7::i64 +extract('DOW'::str, '2016-12-25T13:30:15'::ts) = 0::i64 +extract('DOY'::str, '2016-12-25T13:30:15'::ts) = 360::i64 +extract('HOUR'::str, '2016-12-31T13:30:15'::ts) = 13::i64 +extract('HOUR'::str, '1999-01-08T04:05:06-08:00'::tstz) = 12::i64 +extract('HOUR'::str, '2016-12-31T13:30:15-10:00'::tstz) = 23::i64 +extract('MINUTE'::str, '2016-12-31T13:30:15'::ts) = 30::i64 +extract('SECOND'::str, '2016-12-31T13:30:15'::ts) = 15::i64 +extract('MILLISECONDS'::str, '2016-12-31T13:30:15'::ts) = 15000::i64 +extract('MICROSECONDS'::str, '2016-12-31T13:30:15.220000'::ts) = 15220000::i64 +extract('TIMEZONE'::str, '1999-01-08T04:05:06-08:00'::tstz) = 0::i64 +extract('EPOCH'::str, '2016-12-31T13:30:15'::ts) = 1483191015::i64 + +# date: examples using the date type +extract('YEAR'::str, '2020-12-31'::date) = 2020::i64 +extract('MONTH'::str, '2020-12-31'::date) = 12::i64 +extract('DAY'::str, '2020-12-31'::date) = 31::i64 + +# time: examples using the time type +extract('HOUR'::str, '01:02:03.155900'::time) = 1::i64 +extract('MINUTE'::str, '01:02:03.155900'::time) = 2::i64 +extract('SECOND'::str, '01:02:03.155900'::time) = 3::i64 +extract('MILLISECOND'::str, '01:02:03.155900'::time) = 3000::i64 +extract('MICROSECOND'::str, '01:02:03.45'::time) = 3450000::i64 diff --git a/tests/cases/datetime/gt_datetime.test b/tests/cases/datetime/gt_datetime.test new file mode 100644 index 000000000..5c30851a9 --- /dev/null +++ b/tests/cases/datetime/gt_datetime.test @@ -0,0 +1,25 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_datetime.yaml' + +# timestamps: examples using the timestamp type +gt('2016-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = false::bool +gt('2018-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = true::bool + +# timestamp_tz: examples using the timestamp_tz type +gt('1999-01-08T01:05:05-08:00'::tstz, '1999-01-08T04:05:06-05:00'::tstz) = false::bool +gt('1999-01-08T01:05:07-08:00'::tstz, '1999-01-08T04:05:06-05:00'::tstz) = true::bool + +# date: examples using the date type +gt('2020-12-30'::date, '2020-12-31'::date) = false::bool +gt('2020-12-31'::date, '2020-12-30'::date) = true::bool +gt('P7D'::iday, 'P6D'::iday) = true::bool + +# interval: examples using the interval type +gt('P5D'::iday, 'P6D'::iday) = false::bool +gt('P5Y'::iyear, 'P6Y'::iyear) = false::bool +gt('P7Y'::iyear, 'P6Y'::iyear) = true::bool + +# null_input: examples with null args +gt(null::iday, 'P5D'::iday) = null::bool +gt(null::date, '2020-12-30'::date) = null::bool +gt(null::ts, '2018-12-31T13:30:15'::ts) = null::bool diff --git a/tests/cases/datetime/gte_datetime.test b/tests/cases/datetime/gte_datetime.test new file mode 100644 index 000000000..a1497c843 --- /dev/null +++ b/tests/cases/datetime/gte_datetime.test @@ -0,0 +1,30 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_datetime.yaml' + +# timestamps: examples using the timestamp type +gte('2016-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = false::bool +gte('2017-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = true::bool +gte('2018-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = true::bool + +# timestamp_tz: examples using the timestamp_tz type +gte('1999-01-08T01:05:05-08:00'::tstz, '1999-01-08T04:05:06-05:00'::tstz) = false::bool +gte('1999-01-08T01:05:06-08:00'::tstz, '1999-01-08T01:05:06-08:00'::tstz) = true::bool +gte('1999-01-08T01:05:06-08:00'::tstz, '1999-01-08T04:05:05-05:00'::tstz) = true::bool + +# date: examples using the date type +gte('2020-12-30'::date, '2020-12-31'::date) = false::bool +gte('2020-12-31'::date, '2020-12-31'::date) = true::bool +gte('2020-12-31'::date, '2020-12-30'::date) = true::bool +gte('P7D'::iday, 'P7D'::iday) = true::bool +gte('P7D'::iday, 'P6D'::iday) = true::bool + +# interval: examples using the interval type +gte('P5D'::iday, 'P6D'::iday) = false::bool +gte('P5Y'::iyear, 'P6Y'::iyear) = false::bool +gte('P7Y'::iyear, 'P7Y'::iyear) = true::bool +gte('P7Y'::iyear, 'P6Y'::iyear) = true::bool + +# null_input: examples with null args or return +gte(null::iday, 'P5D'::iday) = null::bool +gte(null::date, '2020-12-30'::date) = null::bool +gte(null::ts, '2018-12-31T13:30:15'::ts) = null::bool diff --git a/tests/cases/datetime/lt_datetime.test b/tests/cases/datetime/lt_datetime.test index a2c14c44d..fa0d9bce6 100644 --- a/tests/cases/datetime/lt_datetime.test +++ b/tests/cases/datetime/lt_datetime.test @@ -12,9 +12,9 @@ lt('1999-01-08T01:05:06-08:00'::tstz, '1999-01-08T04:05:06-05:00'::tstz) = false # date: examples using the date type lt('2020-12-30'::date, '2020-12-31'::date) = true::bool lt('2020-12-31'::date, '2020-12-30'::date) = false::bool +lt('P7D'::iday, 'P6D'::iday) = false::bool # interval: examples using the interval type -lt('P7D'::iday, 'P6D'::iday) = false::bool lt('P5D'::iday, 'P6D'::iday) = true::bool lt('P5Y'::iyear, 'P6Y'::iyear) = true::bool lt('P7Y'::iyear, 'P6Y'::iyear) = false::bool diff --git a/tests/cases/datetime/lte_datetime.test b/tests/cases/datetime/lte_datetime.test new file mode 100644 index 000000000..da5e85145 --- /dev/null +++ b/tests/cases/datetime/lte_datetime.test @@ -0,0 +1,30 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_datetime.yaml' + +# timestamps: examples using the timestamp type +lte('2016-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = true::bool +lte('2017-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = true::bool +lte('2018-12-31T13:30:15'::ts, '2017-12-31T13:30:15'::ts) = false::bool + +# timestamp_tz: examples using the timestamp_tz type +lte('1999-01-08T01:05:05-08:00'::tstz, '1999-01-08T04:05:06-05:00'::tstz) = true::bool +lte('1999-01-08T01:05:06-08:00'::tstz, '1999-01-08T01:05:06-08:00'::tstz) = true::bool +lte('1999-01-08T01:05:06-08:00'::tstz, '1999-01-08T04:05:05-05:00'::tstz) = false::bool + +# date: examples using the date type +lte('2020-12-30'::date, '2020-12-31'::date) = true::bool +lte('2020-12-31'::date, '2020-12-31'::date) = true::bool +lte('2020-12-31'::date, '2020-12-30'::date) = false::bool +lte('P7D'::iday, 'P7D'::iday) = true::bool +lte('P7D'::iday, 'P6D'::iday) = false::bool + +# interval: examples using the interval type +lte('P5D'::iday, 'P6D'::iday) = true::bool +lte('P5Y'::iyear, 'P6Y'::iyear) = true::bool +lte('P7Y'::iyear, 'P7Y'::iyear) = true::bool +lte('P7Y'::iyear, 'P6Y'::iyear) = false::bool + +# null_input: examples with null args or return +lte(null::iday, 'P5D'::iday) = null::bool +lte(null::date, '2020-12-30'::date) = null::bool +lte(null::ts, '2018-12-31T13:30:15'::ts) = null::bool diff --git a/tests/cases/datetime/subtract_datetime.test b/tests/cases/datetime/subtract_datetime.test new file mode 100644 index 000000000..9cc87c9b9 --- /dev/null +++ b/tests/cases/datetime/subtract_datetime.test @@ -0,0 +1,15 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_datetime.yaml' + +# timestamps: examples using the timestamp type +subtract('2016-12-31T13:30:15'::ts, 'P5D'::iday) = '2016-12-26T13:30:15'::ts +subtract('2016-12-01T13:30:15'::ts, 'P5Y'::iyear) = '2011-12-01T13:30:15'::ts +subtract('2016-12-01T13:30:15'::ts, 'PT5H'::iday) = '2016-12-01T08:30:15'::ts + +# date_to_timestamp: examples using the date types and resulting in a timestamp +subtract('2020-12-31'::date, 'P5D'::iday) = '2020-12-26T00:00:00'::ts +subtract('2020-12-31'::date, 'P5Y'::iyear) = '2015-12-31T00:00:00'::ts +subtract('2020-12-31'::date, 'P5M'::iyear) = '2020-07-31T00:00:00'::ts + +# null_input: examples with null args or return +subtract(null::date, 'P5D'::iday) = null::date diff --git a/tests/cases/logarithmic/ln.test b/tests/cases/logarithmic/ln.test new file mode 100644 index 000000000..428d17600 --- /dev/null +++ b/tests/cases/logarithmic/ln.test @@ -0,0 +1,19 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_logarithmic.yaml' + +# basic: Basic examples without any special cases +ln(100000::i64) = 11.512925464970229::fp64 +ln(1.0::fp32) = 0::fp32 +ln(2.015::fp64) = 0.7006191953986464::fp64 +ln(inf::fp64) = inf::fp64 + +# infinity: Examples with infinity as input +ln(-inf::fp64) [on_domain_error:ERROR] = +ln(-inf::fp64) [on_domain_error:NAN] = nan::fp64 +ln(-inf::fp64) [on_domain_error:NONE] = null::fp64 +ln(inf::fp64) = inf::fp64 + +# log_zero: Examples with log zero +ln(0.0::fp64) [on_log_zero:ERROR] = +ln(0.0::fp64) [on_log_zero:NAN] = null::fp64 +ln(0.0::fp64) [on_log_zero:MINUS_INFINITY] = -inf::fp64 diff --git a/tests/cases/logarithmic/log10.test b/tests/cases/logarithmic/log10.test new file mode 100644 index 000000000..811a24790 --- /dev/null +++ b/tests/cases/logarithmic/log10.test @@ -0,0 +1,19 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_logarithmic.yaml' + +# basic: Basic examples without any special cases +log10(100000::i64) = 5.0::fp64 +log10(1.0::fp32) = 0::fp32 +log10(2.015::fp64) = 0.3042750504771283::fp64 +log10(inf::fp64) = inf::fp64 + +# infinity: Examples with infinity as input +log10(-inf::fp64) [on_domain_error:ERROR] = +log10(-inf::fp64) [on_domain_error:NAN] = nan::fp64 +log10(-inf::fp64) [on_domain_error:NONE] = null::fp64 +log10(inf::fp64) = inf::fp64 + +# log_zero: Examples with log zero +log10(0.0::fp64) [on_log_zero:ERROR] = +log10(0.0::fp64) [on_log_zero:NAN] = null::fp64 +log10(0.0::fp64) [on_log_zero:MINUS_INFINITY] = -inf::fp64 diff --git a/tests/cases/logarithmic/log2.test b/tests/cases/logarithmic/log2.test new file mode 100644 index 000000000..0403260d6 --- /dev/null +++ b/tests/cases/logarithmic/log2.test @@ -0,0 +1,20 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_logarithmic.yaml' + +# basic: Basic examples without any special cases +log2(100000::i64) = 16.609640474436812::fp64 +log2(1.0::fp32) = 0::fp32 +log2(8.0::fp64) = 3.0::fp64 +log2(2.015::fp64) = 1.0107798387532427::fp64 +log2(inf::fp64) = inf::fp64 + +# infinity: Examples with infinity as input +log2(-inf::fp64) [on_domain_error:ERROR] = +log2(-inf::fp64) [on_domain_error:NAN] = nan::fp64 +log2(-inf::fp64) [on_domain_error:NONE] = null::fp64 +log2(inf::fp64) = inf::fp64 + +# log_zero: Examples with log zero +log2(0.0::fp64) [on_log_zero:ERROR] = +log2(0.0::fp64) [on_log_zero:NAN] = null::fp64 +log2(0.0::fp64) [on_log_zero:MINUS_INFINITY] = -inf::fp64 diff --git a/tests/cases/logarithmic/logb.test b/tests/cases/logarithmic/logb.test new file mode 100644 index 000000000..50e2f2578 --- /dev/null +++ b/tests/cases/logarithmic/logb.test @@ -0,0 +1,18 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_logarithmic.yaml' + +# basic: Basic examples without any special cases +logb(10::i64, 100000::i64) = 5.0::fp64 +logb(7::fp64, 1.0::fp64) = 0::fp64 +logb(2::fp64, 7::fp64) = 2.8073549220576041::fp64 + +# infinity: Examples with infinity as input +logb(2.34::fp64, inf::fp64) = inf::fp64 +logb(10::fp64, -inf::fp64) [on_domain_error:ERROR] = +logb(10::fp64, -inf::fp64) [on_domain_error:NAN] = nan::fp64 +logb(10::fp64, -inf::fp64) [on_domain_error:NONE] = null::fp64 + +# log_zero: Examples with log zero +logb(2.0::fp64, 0.0::fp64) [on_log_zero:ERROR] = +logb(2.0::fp64, 0.0::fp64) [on_log_zero:NAN] = null::fp64 +logb(2.0::fp64, 0.0::fp64) [on_log_zero:MINUS_INFINITY] = -inf::fp64 diff --git a/tests/cases/rounding/ceil.test b/tests/cases/rounding/ceil.test new file mode 100644 index 000000000..ab1574d42 --- /dev/null +++ b/tests/cases/rounding/ceil.test @@ -0,0 +1,7 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_rounding.yaml' + +# basic: Basic examples without any special cases +ceil(2.25::fp32) = 3::fp32 +ceil(2.0000007152557373046875::fp64) = 3::fp64 +ceil(-65.500000001223334444::fp64) = -65::fp64 diff --git a/tests/cases/rounding/floor.test b/tests/cases/rounding/floor.test new file mode 100644 index 000000000..af1e72ee2 --- /dev/null +++ b/tests/cases/rounding/floor.test @@ -0,0 +1,7 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_rounding.yaml' + +# basic: Basic examples without any special cases +floor(2.25::fp32) = 2::fp32 +floor(2.0000007152557373046875::fp64) = 2::fp64 +floor(-65.490000001223334444::fp64) = -66::fp64 diff --git a/tests/cases/rounding/round.test b/tests/cases/rounding/round.test new file mode 100644 index 000000000..b58f2d0d7 --- /dev/null +++ b/tests/cases/rounding/round.test @@ -0,0 +1,13 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_rounding.yaml' + +# basic: Basic examples without any special cases +round(2::i8, 2::i32) = 2::i8 +round(2.75::fp32, 1::i32) = 2.8::fp32 +round(2.0000007152457373046875::fp64, 10::i32) = 2.0000007152::fp64 +round(2.0000007152457373046875::fp64, 10::i32) = 2.0000007152::fp64 + +# negative_rounding: Examples with negative rounding +round(2::i8, -2::i32) = 0::i8 +round(123::i8, -2::i32) = 100::i8 +round(8793::i16, -2::i32) = 8800::i16 diff --git a/tests/cases/string/bit_length.test b/tests/cases/string/bit_length.test new file mode 100644 index 000000000..df97da059 --- /dev/null +++ b/tests/cases/string/bit_length.test @@ -0,0 +1,16 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +bit_length('abc'::str) = 24::i64 +bit_length(''::str) = 0::i64 +bit_length(' '::str) = 8::i64 +bit_length('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::str) = 384::i64 +bit_length(' 456'::str) = 48::i64 + +# null_input: Examples with null as input +bit_length(null::str) = null::i64 + +# unicode: Examples with unicode characters as input +bit_length('à'::str) = 16::i64 +bit_length('😄'::str) = 32::i64 diff --git a/tests/cases/string/char_length.test b/tests/cases/string/char_length.test new file mode 100644 index 000000000..6b500b4e0 --- /dev/null +++ b/tests/cases/string/char_length.test @@ -0,0 +1,16 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +char_length('abc'::str) = 3::i64 +char_length(''::str) = 0::i64 +char_length(' '::str) = 1::i64 +char_length('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::str) = 48::i64 +char_length(' 456'::str) = 6::i64 + +# null_input: Examples with null as input +char_length(null::str) = null::i64 + +# unicode: Examples with unicode characters as input +char_length('à'::str) = 1::i64 +char_length('😄'::str) = 1::i64 diff --git a/tests/cases/string/concat.test b/tests/cases/string/concat.test new file mode 100644 index 000000000..811e3362d --- /dev/null +++ b/tests/cases/string/concat.test @@ -0,0 +1,13 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +concat('abcd'::str, 'efg'::str) = 'abcdefg'::str + +# null_input: Examples with null as input +concat('abcd'::str, null::str) [null_handling:ACCEPT_NULLS] = null::str +concat('abcd'::str, null::str) [null_handling:IGNORE_NULLS] = 'abcd'::str +concat(null::str, 'abcd'::str) [null_handling:ACCEPT_NULLS] = null::str +concat(null::str, 'abcd'::str) [null_handling:IGNORE_NULLS] = 'abcd'::str +concat(null::str, null::str) [null_handling:ACCEPT_NULLS] = null::str +concat(null::str, null::str) [null_handling:IGNORE_NULLS] = ''::str diff --git a/tests/cases/string/concat_ws.test b/tests/cases/string/concat_ws.test new file mode 100644 index 000000000..6035854a8 --- /dev/null +++ b/tests/cases/string/concat_ws.test @@ -0,0 +1,9 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +concat_ws(','::str, 'Banana'::str, 'Apple'::str, 'Melon'::str) = 'Banana,Apple,Melon'::str +concat_ws(''::str, 'Banana'::str, 'Apple'::str) = 'BananaApple'::str +concat_ws(null::str, 'Banana'::str, 'Apple'::str, 'Melon'::str) = null::str +concat_ws(','::str, null::str, 'Apple'::str, 'Melon'::str) = 'Apple,Melon'::str +concat_ws(','::str, 'Apple'::str, null::str, 'Melon'::str) = 'Apple,Melon'::str diff --git a/tests/cases/string/contains.test b/tests/cases/string/contains.test new file mode 100644 index 000000000..92d7338ef --- /dev/null +++ b/tests/cases/string/contains.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples contains as prefix +contains('abcdefg'::str, 'abc'::str) = true::bool +contains('abcdefg'::str, 'CdE'::str) [case_sensitivity:CASE_INSENSITIVE] = true::bool +contains('abcdefg'::str, 'cde'::str) = true::bool +contains('abcdefg'::str, 'fg'::str) = true::bool +contains('abcdefg'::str, 'aef'::str) = false::bool + +# multi_byte_characters: multi byte characters exists in the string +contains('😊a😊b😊😊'::str, 'a😊b'::str) = true::bool +contains('😊a😊b😊😊'::str, 'A😊B'::str) [case_sensitivity:CASE_INSENSITIVE] = true::bool +contains('😊a😊b😊😊'::str, 'a😊c'::str) = false::bool diff --git a/tests/cases/string/ends_with.test b/tests/cases/string/ends_with.test new file mode 100644 index 000000000..aa4dbbe03 --- /dev/null +++ b/tests/cases/string/ends_with.test @@ -0,0 +1,15 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +ends_with('abcd'::str, 'd'::str) = true::bool +ends_with('abcd'::str, 'a'::str) = false::bool + +# case_insenstivity: multi byte character comparison with case insensitivity +ends_with('abcd'::str, 'CD'::str) [case_sensitivity:CASE_INSENSITIVE] = true::bool + +# multi_byte_characters: multi byte character comparison +ends_with('😊a😊b😊😊'::str, 'b😊😊'::str) = true::bool + +# multi_byte_characters case insensitivity: multi byte character comparison with case insensitivity +ends_with('😊a😊b😊😊'::str, 'B😊😊'::str) [case_sensitivity:CASE_INSENSITIVE] = true::bool diff --git a/tests/cases/string/left.test b/tests/cases/string/left.test new file mode 100644 index 000000000..45bdaa8fd --- /dev/null +++ b/tests/cases/string/left.test @@ -0,0 +1,14 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +left('abcdef'::str, 2::i32) = 'ab'::str +left('abcdef'::str, 6::i32) = 'abcdef'::str +left('abcdef'::str, 10::i32) = 'abcdef'::str +left(' abcdef abcdef'::str, 10::i32) = ' abcdef '::str +left(null::str, 10::i32) = null::str +left('abcdef'::str, null::i32) = null::str + +# unicode: Examples with unicode characters as input +left('ææããa'::str, 2::i32) = 'ææ'::str +left('😔😄😔😄'::str, 2::i32) = '😔😄'::str diff --git a/tests/cases/string/like.test b/tests/cases/string/like.test new file mode 100644 index 000000000..c01003fb3 --- /dev/null +++ b/tests/cases/string/like.test @@ -0,0 +1,12 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +like('abcdefg'::str, 'abcdefg'::str) = true::bool +like('abcdefg'::str, 'abc'::str) = false::bool + +# wildcard: Examples using wildcards +like('abcdefg'::str, 'abc%'::str) = true::bool +like('abcdefg'::str, '%efg'::str) = true::bool +like('abcdefg'::str, '_bcdefg'::str) = true::bool +like('abcdefg'::str, 'abc_efg'::str) = true::bool diff --git a/tests/cases/string/lower.test b/tests/cases/string/lower.test new file mode 100644 index 000000000..7ef916789 --- /dev/null +++ b/tests/cases/string/lower.test @@ -0,0 +1,15 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +lower('ABC'::str) = 'abc'::str +lower('aBc'::str) = 'abc'::str +lower('abc'::str) = 'abc'::str +lower(''::str) = ''::str + +# null_input: Examples with null as input +lower(null::str) = null::str + +# unicode: Examples with unicode characters as input +lower('ÆÆÃÃA'::str) [full_unicode:TRUE] = 'ææããa'::str +lower('😄'::str) = '😄'::str diff --git a/tests/cases/string/lpad.test b/tests/cases/string/lpad.test new file mode 100644 index 000000000..fc74b01ee --- /dev/null +++ b/tests/cases/string/lpad.test @@ -0,0 +1,13 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +lpad('abcdef'::str, 10::i32, ' '::str) = ' abcdef'::str +lpad('abcdef '::str, 20::i32, '1'::str) = '1111111111abcdef '::str +lpad(' abcdef'::str, 20::i32, '1'::str) = '1111111111 abcdef'::str +lpad('abcdef'::str, 6::i32, ' '::str) = 'abcdef'::str +lpad('abcdef'::str, 20::i32, 'aabb'::str) = 'aabbaabbaabbaaabcdef'::str +lpad('abcdef'::str, 4::i32, ' '::str) = 'abcd'::str +lpad('abcdef'::str, -1::i32, ' '::str) = ''::str +lpad(null::str, 4::i32, ' '::str) = null::str +lpad('abcdef'::str, 10::i32, null::str) = null::str diff --git a/tests/cases/string/ltrim.test b/tests/cases/string/ltrim.test new file mode 100644 index 000000000..7eb9728fa --- /dev/null +++ b/tests/cases/string/ltrim.test @@ -0,0 +1,16 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +ltrim('abc'::str) = 'abc'::str +ltrim(' abc'::str) = 'abc'::str +ltrim('abc '::str) = 'abc '::str +ltrim(' abc '::str) = 'abc '::str +ltrim(''::str) = ''::str +ltrim(' '::str) = ''::str +ltrim(null::str) = null::str + +# two_inputs: Examples with character input to trim off +ltrim('aaaaabc'::str, 'a'::str) [spaces_only:FALSE] = 'bc'::str +ltrim('abcabcdef'::str, 'abc'::str) [spaces_only:FALSE] = 'def'::str +ltrim('abccbadef'::str, 'abc'::str) [spaces_only:FALSE] = 'def'::str diff --git a/tests/cases/string/octet_length.test b/tests/cases/string/octet_length.test new file mode 100644 index 000000000..9adb1a192 --- /dev/null +++ b/tests/cases/string/octet_length.test @@ -0,0 +1,16 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +octet_length('abc'::str) = 3::i64 +octet_length(''::str) = 0::i64 +octet_length(' '::str) = 1::i64 +octet_length('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::str) = 48::i64 +octet_length(' 456'::str) = 6::i64 + +# null_input: Examples with null as input +octet_length(null::str) = null::i64 + +# unicode: Examples with unicode characters as input +octet_length('à'::str) = 2::i64 +octet_length('😄'::str) = 4::i64 diff --git a/tests/cases/string/regexp_count_substring.test b/tests/cases/string/regexp_count_substring.test new file mode 100644 index 000000000..67778734f --- /dev/null +++ b/tests/cases/string/regexp_count_substring.test @@ -0,0 +1,33 @@ +### SUBSTRAIT_SCALAR_TEST: v1.0 +### SUBSTRAIT_INCLUDE: '/extensions/functions_string.yaml' + +# basic: Basic examples without any special cases +regexp_count_substring('foobarboopzoo'::str, 'o{1,}'::str) = 3::i64 +regexp_count_substring('foobarboopzoo'::str, 'o{1}'::str) = 6::i64 +regexp_count_substring('abcabcacb'::str, '[bc]'::str) = 6::i64 +regexp_count_substring('abcdefc'::str, '(.*)c'::str) = 1::i64 +regexp_count_substring('abcdefc'::str, '(.*)c?'::str) = 2::i64 + +# null_input: Examples with null as input +regexp_count_substring('Hello'::str, null::str) = null::i64 +regexp_count_substring(null::str, ' '::str) = null::i64 + +# metacharacters: Examples with metacharacters +regexp_count_substring('abc1abc'::str, '\d'::str) = 1::i64 +regexp_count_substring('abc1abc'::str, '\D'::str) = 6::i64 +regexp_count_substring('abc def ghi'::str, '\s'::str) = 2::i64 +regexp_count_substring('abc def ghi'::str, '\S'::str) = 9::i64 +regexp_count_substring('abc def ghi'::str, '\w'::str) = 9::i64 +regexp_count_substring('abc def ghi,'::str, '\W'::str) = 3::i64 + +# lookahead: Examples with lookahead +regexp_count_substring('100 dollars 100 dollars'::str, '\d+(?= dollars)'::str) [lookaround:TRUE] = 2::i64 + +# negative_lookahead: Examples with negative lookahead +regexp_count_substring('100 pesos, 99 pesos, 98 pesos'::str, '\d+(?!\d| dollars)'::str) [lookaround:TRUE] = 3::i64 + +# lookbehind: Examples with lookbehind +regexp_count_substring('USD100'::str, '(?<=USD)\d{3}'::str) [lookaround:TRUE] = 1::i64 + +# negative_lookbehind: Examples with negative lookbehind +regexp_count_substring('JPY100JPY100'::str, '\d{3}(?