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/library | |
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/library')
24 files changed, 129 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/library/agg.sql.txt b/yql/essentials/tests/sql/suites/library/agg.sql.txt new file mode 100644 index 0000000000..4785684f11 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/agg.sql.txt @@ -0,0 +1,7 @@ +-- Агрегационные функции, создаваемые с помощью +-- AggregationFactory, удобно выносить в библиотеку +$Agg_sum = AggregationFactory("SUM"); +$Agg_max = AggregationFactory("MAX"); + +EXPORT $Agg_sum, $Agg_max; + diff --git a/yql/essentials/tests/sql/suites/library/forward_import.cfg b/yql/essentials/tests/sql/suites/library/forward_import.cfg new file mode 100644 index 0000000000..665f5854f9 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/forward_import.cfg @@ -0,0 +1,2 @@ +file agg.sql agg.sql.txt +file lib.sql lib.sql.txt diff --git a/yql/essentials/tests/sql/suites/library/forward_import.sql b/yql/essentials/tests/sql/suites/library/forward_import.sql new file mode 100644 index 0000000000..8e0b95d44c --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/forward_import.sql @@ -0,0 +1,16 @@ +/* postgres can not */ +/* syntax version 1 */ +PRAGMA Library("agg.sql"); +PRAGMA Library("lib.sql"); + +IMPORT lib SYMBOLS $Square, $Agg_sum, $Agg_max; +SELECT $Square(2); + +SELECT + AGGREGATE_BY(x, $Agg_sum), + AGGREGATE_BY(x, $Agg_max) +FROM ( + SELECT 2 AS x + UNION ALL + SELECT 3 AS x +) diff --git a/yql/essentials/tests/sql/suites/library/lib.sql.txt b/yql/essentials/tests/sql/suites/library/lib.sql.txt new file mode 100644 index 0000000000..5860176b7a --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/lib.sql.txt @@ -0,0 +1,6 @@ +IMPORT agg SYMBOLS $Agg_sum, $Agg_max; + +$Square = ($x) -> { RETURN $x * $x; }; + +EXPORT $Square, $Agg_sum, $Agg_max; + diff --git a/yql/essentials/tests/sql/suites/library/lib1.sql.txt b/yql/essentials/tests/sql/suites/library/lib1.sql.txt new file mode 100644 index 0000000000..0de921bca3 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/lib1.sql.txt @@ -0,0 +1,5 @@ +import lib2 symbols $mul; + +$sqr = ($x)->{ return $mul($x, $x); }; + +export $sqr; diff --git a/yql/essentials/tests/sql/suites/library/lib2.sql.txt b/yql/essentials/tests/sql/suites/library/lib2.sql.txt new file mode 100644 index 0000000000..22d768ac39 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/lib2.sql.txt @@ -0,0 +1,3 @@ +$mul = ($x, $y)->{ return $x*$y; }; + +export $mul; diff --git a/yql/essentials/tests/sql/suites/library/library.cfg b/yql/essentials/tests/sql/suites/library/library.cfg new file mode 100644 index 0000000000..24ecbe21c2 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library.cfg @@ -0,0 +1,2 @@ +file lib1.sql lib1.sql.txt +file lib2.sql lib2.sql.txt
\ No newline at end of file diff --git a/yql/essentials/tests/sql/suites/library/library.sql b/yql/essentials/tests/sql/suites/library/library.sql new file mode 100644 index 0000000000..72213f6655 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library.sql @@ -0,0 +1,6 @@ +/* postgres can not */ +/* kikimr can not - range not supported */ +pragma library("lib1.sql"); +pragma library("lib2.sql"); +import lib1 symbols $sqr; +select $sqr(10); diff --git a/yql/essentials/tests/sql/suites/library/library_alias.cfg b/yql/essentials/tests/sql/suites/library/library_alias.cfg new file mode 100644 index 0000000000..259944aff0 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library_alias.cfg @@ -0,0 +1 @@ +file lib2.sql lib2.sql.txt diff --git a/yql/essentials/tests/sql/suites/library/library_alias.sql b/yql/essentials/tests/sql/suites/library/library_alias.sql new file mode 100644 index 0000000000..681d569cbc --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library_alias.sql @@ -0,0 +1,4 @@ +/* postgres can not */ +pragma library("lib2.sql"); +import lib2 symbols $mul as $multiply; +select $multiply(2,3); diff --git a/yql/essentials/tests/sql/suites/library/library_udf.cfg b/yql/essentials/tests/sql/suites/library/library_udf.cfg new file mode 100644 index 0000000000..720705143d --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library_udf.cfg @@ -0,0 +1,2 @@ +file udf.sql udf.sql.txt +udf string_udf diff --git a/yql/essentials/tests/sql/suites/library/library_udf.sql b/yql/essentials/tests/sql/suites/library/library_udf.sql new file mode 100644 index 0000000000..42eff53997 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library_udf.sql @@ -0,0 +1,5 @@ +/* postgres can not */ +/* kikimr can not - range not supported */ +pragma Library("udf.sql"); +import udf symbols $f; +select $f; diff --git a/yql/essentials/tests/sql/suites/library/library_via_http.cfg b/yql/essentials/tests/sql/suites/library/library_via_http.cfg new file mode 100644 index 0000000000..666586ba14 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library_via_http.cfg @@ -0,0 +1,2 @@ +http_file lib1.sql lib1.sql.txt +http_file lib2.sql lib2.sql.txt
\ No newline at end of file diff --git a/yql/essentials/tests/sql/suites/library/library_via_http.sql b/yql/essentials/tests/sql/suites/library/library_via_http.sql new file mode 100644 index 0000000000..72213f6655 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/library_via_http.sql @@ -0,0 +1,6 @@ +/* postgres can not */ +/* kikimr can not - range not supported */ +pragma library("lib1.sql"); +pragma library("lib2.sql"); +import lib1 symbols $sqr; +select $sqr(10); diff --git a/yql/essentials/tests/sql/suites/library/p_package_cluster.json b/yql/essentials/tests/sql/suites/library/p_package_cluster.json new file mode 100644 index 0000000000..8824674974 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/p_package_cluster.json @@ -0,0 +1 @@ +"plato" diff --git a/yql/essentials/tests/sql/suites/library/package.cfg b/yql/essentials/tests/sql/suites/library/package.cfg new file mode 100644 index 0000000000..2ec4243a95 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package.cfg @@ -0,0 +1,5 @@ +providers yt +yt_file yt://plato/package/total.sql package_total.sql.txt +yt_file yt://plato/package/detail/foo.sql package_foo.sql.txt +yt_file yt://plato/package/detail/bar.sql package_bar.sql.txt +param $cluster p_package_cluster.json diff --git a/yql/essentials/tests/sql/suites/library/package.sql b/yql/essentials/tests/sql/suites/library/package.sql new file mode 100644 index 0000000000..e649b298a2 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package.sql @@ -0,0 +1,9 @@ +/* ytfile can not */ + +declare $cluster as String; + +pragma package("project.package", "yt://{$cluster}/package"); + +import pkg.project.package.total symbols $do_total; + +select $do_total(1); diff --git a/yql/essentials/tests/sql/suites/library/package_bar.sql.txt b/yql/essentials/tests/sql/suites/library/package_bar.sql.txt new file mode 100644 index 0000000000..adef3c7744 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package_bar.sql.txt @@ -0,0 +1,7 @@ +$do_bar = ($value) -> { + return AsStruct( + $value as bar + ); +}; + +export $do_bar; diff --git a/yql/essentials/tests/sql/suites/library/package_bar_override.sql.txt b/yql/essentials/tests/sql/suites/library/package_bar_override.sql.txt new file mode 100644 index 0000000000..99244e08e3 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package_bar_override.sql.txt @@ -0,0 +1,7 @@ +$do_bar = ($value) -> { + return AsStruct( + $value as bar_override + ); +}; + +export $do_bar; diff --git a/yql/essentials/tests/sql/suites/library/package_foo.sql.txt b/yql/essentials/tests/sql/suites/library/package_foo.sql.txt new file mode 100644 index 0000000000..88f9288369 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package_foo.sql.txt @@ -0,0 +1,7 @@ +$do_foo = ($value) -> { + return AsStruct( + $value as foo + ); +}; + +export $do_foo; diff --git a/yql/essentials/tests/sql/suites/library/package_override.cfg b/yql/essentials/tests/sql/suites/library/package_override.cfg new file mode 100644 index 0000000000..5cc9b05eda --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package_override.cfg @@ -0,0 +1,5 @@ +providers yt +file pkg/project/package/detail/bar.sql package_bar_override.sql.txt +yt_file yt://plato/package/total.sql package_total.sql.txt +yt_file yt://plato/package/detail/foo.sql package_foo.sql.txt +yt_file yt://plato/package/detail/bar.sql package_bar.sql.txt diff --git a/yql/essentials/tests/sql/suites/library/package_override.sql b/yql/essentials/tests/sql/suites/library/package_override.sql new file mode 100644 index 0000000000..bd0b2c7625 --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package_override.sql @@ -0,0 +1,8 @@ +/* ytfile can not */ + +pragma package("project.package", "yt://plato/package"); +pragma override_library("project/package/detail/bar.sql"); + +import pkg.project.package.total symbols $do_total; + +select $do_total(1); diff --git a/yql/essentials/tests/sql/suites/library/package_total.sql.txt b/yql/essentials/tests/sql/suites/library/package_total.sql.txt new file mode 100644 index 0000000000..c1677315ac --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/package_total.sql.txt @@ -0,0 +1,11 @@ +import pkg.project.package.detail.foo symbols $do_foo; +import pkg.project.package.detail.bar symbols $do_bar; + +$do_total = ($value) -> { + $foo = $do_foo($value); + $bar = $do_bar($value); + + return ($foo, $bar); +}; + +export $do_total; diff --git a/yql/essentials/tests/sql/suites/library/udf.sql.txt b/yql/essentials/tests/sql/suites/library/udf.sql.txt new file mode 100644 index 0000000000..1c7a2afd0f --- /dev/null +++ b/yql/essentials/tests/sql/suites/library/udf.sql.txt @@ -0,0 +1,2 @@ +$f = Unicode::ToUpper("foo"u); +export $f; |