diff options
author | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-19 14:58:38 +0300 |
---|---|---|
committer | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-19 15:16:27 +0300 |
commit | 24521403b1c44303e043ba540c09b1fe991c7474 (patch) | |
tree | 341d1e7206bc7c143d04d2d96f05b6dc0655606d /yql/essentials/tests/sql/suites/coalesce | |
parent | 72b3cd51dc3fb9d16975d353ea82fd85701393cc (diff) | |
download | ydb-24521403b1c44303e043ba540c09b1fe991c7474.tar.gz |
YQL-19206 Move contrib/ydb/library/yql/tests/sql/suites -> yql/essentials/tests/sql/suites
commit_hash:d0ef1f92b09c94db7c2408f946d2a4c62b603f00
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" + ] + ] + ] + ] + ] + ] + ]}; +} |