diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-20 17:37:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 17:37:57 +0000 |
commit | f76323e9b295c15751e51e3443aa47a36bee8023 (patch) | |
tree | 4113c8cad473a33e0f746966e0cf087252fa1d7a /yql/essentials/tests/sql/suites/coalesce | |
parent | 753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff) | |
parent | a7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff) | |
download | ydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz |
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'yql/essentials/tests/sql/suites/coalesce')
12 files changed, 154 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/coalesce/coalesce.cfg b/yql/essentials/tests/sql/suites/coalesce/coalesce.cfg new file mode 100644 index 0000000000..5640285809 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/coalesce.cfg @@ -0,0 +1 @@ +in Input input_coalesce.txt diff --git a/yql/essentials/tests/sql/suites/coalesce/coalesce.sql b/yql/essentials/tests/sql/suites/coalesce/coalesce.sql new file mode 100644 index 0000000000..92c4778505 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/coalesce.sql @@ -0,0 +1 @@ +select coalesce(cast(value as int), 999) from plato.Input;
\ No newline at end of file diff --git a/yql/essentials/tests/sql/suites/coalesce/coalesce_few_opt.cfg b/yql/essentials/tests/sql/suites/coalesce/coalesce_few_opt.cfg new file mode 100644 index 0000000000..64b3f61710 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/coalesce_few_opt.cfg @@ -0,0 +1 @@ +in Input optional.txt diff --git a/yql/essentials/tests/sql/suites/coalesce/coalesce_few_opt.sql b/yql/essentials/tests/sql/suites/coalesce/coalesce_few_opt.sql new file mode 100644 index 0000000000..1e2d541f60 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/coalesce_few_opt.sql @@ -0,0 +1,24 @@ +select + 'first', + coalesce(first_null, 22), + coalesce(first_num, 33), + coalesce(coalesce(first_null, 122), 42), + coalesce(coalesce(first_num, 133), 43), + coalesce(coalesce(coalesce(first_null, 222), 442), 100500), + coalesce(coalesce(coalesce(first_num, 233), 443), 100501), + 'second', + coalesce(second_null, 22), + coalesce(second_num, 33), + coalesce(coalesce(second_null, 122), 42), + coalesce(coalesce(second_num, 133), 43), + coalesce(coalesce(coalesce(second_null, 222), 442), 100500), + coalesce(coalesce(coalesce(second_num, 233), 443), 100501), + 'third', + coalesce(third_null, 22), + coalesce(third_num, 33), + coalesce(coalesce(third_null, 122), 42), + coalesce(coalesce(third_num, 133), 43), + coalesce(coalesce(coalesce(third_null, 222), 442), 100500), + coalesce(coalesce(coalesce(third_num, 233), 443), 100501), + 'end' +from plato.Input; diff --git a/yql/essentials/tests/sql/suites/coalesce/coalesce_few_real.sql b/yql/essentials/tests/sql/suites/coalesce/coalesce_few_real.sql new file mode 100644 index 0000000000..0eebc69cc2 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/coalesce_few_real.sql @@ -0,0 +1,17 @@ +/* postgres can not */ +$optDuoFloat=Just(Just(cast(2.71 as float))); +$optDuoDouble=Just(Just(cast(3.14 as double))); +$optDuoFloatN=Just(Just(cast(null as float))); +$optDuoDoubleN=Just(Just(cast(null as double))); + +select + ($optDuoFloat ?? 0) ?? 1, + ($optDuoDouble ?? 41) ?? 42, + ($optDuoFloatN ?? 0) ?? 1., + ($optDuoDoubleN ?? 41.) ?? 42, + ($optDuoFloatN ?? cast(40.1 as float)) ?? cast(40.2 as float), + ($optDuoDoubleN ?? cast(40.1 as float)) ?? cast(40.2 as float), + (($optDuoFloatN ?? 0) ?? 1.) ?? 3, + (($optDuoDoubleN ?? 41) ?? 42) ?? 4, + 'end' +from plato.Input; diff --git a/yql/essentials/tests/sql/suites/coalesce/coalesce_sugar.sql b/yql/essentials/tests/sql/suites/coalesce/coalesce_sugar.sql new file mode 100644 index 0000000000..c9d2442ee8 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/coalesce_sugar.sql @@ -0,0 +1,3 @@ +/* postgres can not */ +$data = (select key, cast(key as Int64)/100 as eval from plato.Input); +select case when eval < 5 then eval else cast(Null as Int64) end ?? -1, key from $data; diff --git a/yql/essentials/tests/sql/suites/coalesce/coalesce_symmetry.sql b/yql/essentials/tests/sql/suites/coalesce/coalesce_symmetry.sql new file mode 100644 index 0000000000..393796816f --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/coalesce_symmetry.sql @@ -0,0 +1,11 @@ +/* postgres can not */ +$x = 1 + 0; +$y = 2ul + 0ul; +select $x ?? $y; +select $y ?? $x; +select Just($x) ?? $y; +select $y ?? Just($x); +select $x ?? Just($y); +select Just($y) ?? $x; +select Just($x) ?? Just($y); +select Just($y) ?? Just($x); diff --git a/yql/essentials/tests/sql/suites/coalesce/default.cfg b/yql/essentials/tests/sql/suites/coalesce/default.cfg new file mode 100644 index 0000000000..a1f7a5a9b7 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/default.cfg @@ -0,0 +1,4 @@ +in Input input.txt +in Input2 input2.txt +in Input3 input3.txt +in Input4 input4.txt diff --git a/yql/essentials/tests/sql/suites/coalesce/input.txt b/yql/essentials/tests/sql/suites/coalesce/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/input.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="qzz"}; diff --git a/yql/essentials/tests/sql/suites/coalesce/input_coalesce.txt b/yql/essentials/tests/sql/suites/coalesce/input_coalesce.txt new file mode 100644 index 0000000000..acc680146e --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/input_coalesce.txt @@ -0,0 +1,2 @@ +{"key"="1";"subkey"="2";"value"="3"}; +{"key"="4";"subkey"="5";"value"="x"}; diff --git a/yql/essentials/tests/sql/suites/coalesce/optional.txt b/yql/essentials/tests/sql/suites/coalesce/optional.txt new file mode 100644 index 0000000000..74737be93c --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/optional.txt @@ -0,0 +1 @@ +{"first_num"=1u; "first_null"=#; "second_num"=[1u]; "second_null"=[]; "third_num"=[[1u]]; "third_null"=[#]}; diff --git a/yql/essentials/tests/sql/suites/coalesce/optional.txt.attr b/yql/essentials/tests/sql/suites/coalesce/optional.txt.attr new file mode 100644 index 0000000000..7962199d3e --- /dev/null +++ b/yql/essentials/tests/sql/suites/coalesce/optional.txt.attr @@ -0,0 +1,85 @@ +{ + "_yql_row_spec" = {"Type" = [ + "StructType"; + [ + [ + "first_null"; + [ + "OptionalType"; + [ + "DataType"; + "Uint32" + ] + ] + ]; + [ + "first_num"; + [ + "OptionalType"; + [ + "DataType"; + "Uint32" + ] + ] + ]; + [ + "second_null"; + [ + "OptionalType"; + [ + "OptionalType"; + [ + "DataType"; + "Uint32" + ] + ] + ] + ]; + [ + "second_num"; + [ + "OptionalType"; + [ + "OptionalType"; + [ + "DataType"; + "Uint32" + ] + ] + ] + ]; + [ + "third_null"; + [ + "OptionalType"; + [ + "OptionalType"; + [ + "OptionalType"; + [ + "DataType"; + "Uint32" + ] + ] + ] + ] + ]; + [ + "third_num"; + [ + "OptionalType"; + [ + "OptionalType"; + [ + "OptionalType"; + [ + "DataType"; + "Uint32" + ] + ] + ] + ] + ] + ] + ]}; +} |