diff options
author | aozeritsky <aozeritsky@ydb.tech> | 2023-09-21 13:24:42 +0300 |
---|---|---|
committer | aozeritsky <aozeritsky@ydb.tech> | 2023-09-21 14:03:58 +0300 |
commit | ac2e69d76aea1a38a68716ce59c3c072b53d81c2 (patch) | |
tree | 7945b0c0dc952d2ee300e8a8f9e6813c0732f2d7 | |
parent | 515937292bc546d9134ab26ab1e8c50b69ff0900 (diff) | |
download | ydb-ac2e69d76aea1a38a68716ce59c3c072b53d81c2.tar.gz |
Move common-cbo test parts to apropriate place
-rw-r--r-- | ydb/library/yql/core/cbo/CMakeLists.darwin-x86_64.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/CMakeLists.linux-aarch64.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/CMakeLists.linux-x86_64.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/CMakeLists.windows-x86_64.txt | 1 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp | 87 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/ut/CMakeLists.darwin-x86_64.txt | 65 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/ut/CMakeLists.linux-aarch64.txt | 70 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/ut/CMakeLists.linux-x86_64.txt | 72 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/ut/CMakeLists.txt | 17 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/ut/CMakeLists.windows-x86_64.txt | 60 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/ut/ya.make | 13 | ||||
-rw-r--r-- | ydb/library/yql/core/cbo/ya.make | 4 | ||||
-rw-r--r-- | ydb/library/yql/sql/pg/optimizer_ut.cpp | 77 |
13 files changed, 392 insertions, 77 deletions
diff --git a/ydb/library/yql/core/cbo/CMakeLists.darwin-x86_64.txt b/ydb/library/yql/core/cbo/CMakeLists.darwin-x86_64.txt index 64f3490aa79..a06e4ec3c65 100644 --- a/ydb/library/yql/core/cbo/CMakeLists.darwin-x86_64.txt +++ b/ydb/library/yql/core/cbo/CMakeLists.darwin-x86_64.txt @@ -6,6 +6,7 @@ # original buildsystem will not be accepted. +add_subdirectory(ut) add_library(yql-core-cbo) target_link_libraries(yql-core-cbo PUBLIC diff --git a/ydb/library/yql/core/cbo/CMakeLists.linux-aarch64.txt b/ydb/library/yql/core/cbo/CMakeLists.linux-aarch64.txt index 70a3d8682eb..c90606d74fb 100644 --- a/ydb/library/yql/core/cbo/CMakeLists.linux-aarch64.txt +++ b/ydb/library/yql/core/cbo/CMakeLists.linux-aarch64.txt @@ -6,6 +6,7 @@ # original buildsystem will not be accepted. +add_subdirectory(ut) add_library(yql-core-cbo) target_link_libraries(yql-core-cbo PUBLIC diff --git a/ydb/library/yql/core/cbo/CMakeLists.linux-x86_64.txt b/ydb/library/yql/core/cbo/CMakeLists.linux-x86_64.txt index 70a3d8682eb..c90606d74fb 100644 --- a/ydb/library/yql/core/cbo/CMakeLists.linux-x86_64.txt +++ b/ydb/library/yql/core/cbo/CMakeLists.linux-x86_64.txt @@ -6,6 +6,7 @@ # original buildsystem will not be accepted. +add_subdirectory(ut) add_library(yql-core-cbo) target_link_libraries(yql-core-cbo PUBLIC diff --git a/ydb/library/yql/core/cbo/CMakeLists.windows-x86_64.txt b/ydb/library/yql/core/cbo/CMakeLists.windows-x86_64.txt index 64f3490aa79..a06e4ec3c65 100644 --- a/ydb/library/yql/core/cbo/CMakeLists.windows-x86_64.txt +++ b/ydb/library/yql/core/cbo/CMakeLists.windows-x86_64.txt @@ -6,6 +6,7 @@ # original buildsystem will not be accepted. +add_subdirectory(ut) add_library(yql-core-cbo) target_link_libraries(yql-core-cbo PUBLIC diff --git a/ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp b/ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp new file mode 100644 index 00000000000..0156903569f --- /dev/null +++ b/ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp @@ -0,0 +1,87 @@ +#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/hook/hook.h> + +#include "cbo_optimizer.h" + +using namespace NYql; + +Y_UNIT_TEST_SUITE(CboOptimizer) { + +Y_UNIT_TEST(InputToString) { + IOptimizer::TRel rel1 = {100000, 1000000, {{'a'}}}; + IOptimizer::TRel rel2 = {1000000, 9000009, {{'b'}}}; + IOptimizer::TRel rel3 = {10000, 9009, {{'c'}}}; + IOptimizer::TInput input = {{rel1, rel2, rel3}, {}, {}, {}}; + + input.EqClasses.emplace_back(IOptimizer::TEq { + {{1, 1}, {2, 1}, {3, 1}} + }); + + auto str = input.ToString(); + + TString expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, +{rows: 1000000,cost: 9000009,vars: [b]}, +{rows: 10000,cost: 9009,vars: [c]}] +EqClasses: [[a,b,c]] +)__"; + UNIT_ASSERT_STRINGS_EQUAL(expected, str); +} + +Y_UNIT_TEST(InputNormalize) { + IOptimizer::TRel rel1 = {100000, 1000000, {{'a'}}}; + IOptimizer::TRel rel2 = {1000000, 9000009, {{'b'}}}; + IOptimizer::TRel rel3 = {10000, 9009, {{'c'}}}; + IOptimizer::TInput input = {{rel1, rel2, rel3}, {}, {}, {}}; + + input.EqClasses.emplace_back(IOptimizer::TEq { + {{1, 1}, {2, 1}} + }); + input.EqClasses.emplace_back(IOptimizer::TEq { + {{2, 1}, {3, 1}} + }); + + TString expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, +{rows: 1000000,cost: 9000009,vars: [b]}, +{rows: 10000,cost: 9009,vars: [c]}] +EqClasses: [[a,b],[b,c]] +)__"; + UNIT_ASSERT_STRINGS_EQUAL(expected, input.ToString()); + + input.Normalize(); + + expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, +{rows: 1000000,cost: 9000009,vars: [b]}, +{rows: 10000,cost: 9009,vars: [c]}] +EqClasses: [[a,b,c]] +)__"; + UNIT_ASSERT_STRINGS_EQUAL(expected, input.ToString()); + + IOptimizer::TRel rel4 = {10001, 9009, {{'d'}}}; + IOptimizer::TInput input2 = {{rel1, rel2, rel3, rel4}, {}, {}, {}}; + input2.EqClasses.emplace_back(IOptimizer::TEq { + {{1, 1}, {2, 1}} + }); + input2.EqClasses.emplace_back(IOptimizer::TEq { + {{4, 1}, {3, 1}} + }); + + expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, +{rows: 1000000,cost: 9000009,vars: [b]}, +{rows: 10000,cost: 9009,vars: [c]}, +{rows: 10001,cost: 9009,vars: [d]}] +EqClasses: [[a,b],[d,c]] +)__"; + UNIT_ASSERT_STRINGS_EQUAL(expected, input2.ToString()); + + input2.Normalize(); + + expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, +{rows: 1000000,cost: 9000009,vars: [b]}, +{rows: 10000,cost: 9009,vars: [c]}, +{rows: 10001,cost: 9009,vars: [d]}] +EqClasses: [[a,b],[c,d]] +)__"; + UNIT_ASSERT_STRINGS_EQUAL(expected, input2.ToString()); +} + +} // Y_UNIT_TEST_SUITE(CboOptimizer) diff --git a/ydb/library/yql/core/cbo/ut/CMakeLists.darwin-x86_64.txt b/ydb/library/yql/core/cbo/ut/CMakeLists.darwin-x86_64.txt new file mode 100644 index 00000000000..cb1a714c04d --- /dev/null +++ b/ydb/library/yql/core/cbo/ut/CMakeLists.darwin-x86_64.txt @@ -0,0 +1,65 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_executable(ydb-library-yql-core-cbo-ut) +target_include_directories(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo +) +target_link_libraries(ydb-library-yql-core-cbo-ut PUBLIC + contrib-libs-cxxsupp + yutil + library-cpp-cpuid_check + cpp-testing-unittest_main + yql-core-cbo +) +target_link_options(ydb-library-yql-core-cbo-ut PRIVATE + -Wl,-platform_version,macos,11.0,11.0 + -fPIC + -fPIC +) +target_sources(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp +) +set_property( + TARGET + ydb-library-yql-core-cbo-ut + PROPERTY + SPLIT_FACTOR + 1 +) +add_yunittest( + NAME + ydb-library-yql-core-cbo-ut + TEST_TARGET + ydb-library-yql-core-cbo-ut + TEST_ARG + --print-before-suite + --print-before-test + --fork-tests + --print-times + --show-fails +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + LABELS + SMALL +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + PROCESSORS + 1 +) +target_allocator(ydb-library-yql-core-cbo-ut + system_allocator +) +vcs_info(ydb-library-yql-core-cbo-ut) diff --git a/ydb/library/yql/core/cbo/ut/CMakeLists.linux-aarch64.txt b/ydb/library/yql/core/cbo/ut/CMakeLists.linux-aarch64.txt new file mode 100644 index 00000000000..da291f0a8c8 --- /dev/null +++ b/ydb/library/yql/core/cbo/ut/CMakeLists.linux-aarch64.txt @@ -0,0 +1,70 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_executable(ydb-library-yql-core-cbo-ut) +target_include_directories(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo +) +target_link_libraries(ydb-library-yql-core-cbo-ut PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + cpp-testing-unittest_main + yql-core-cbo +) +target_link_options(ydb-library-yql-core-cbo-ut PRIVATE + -ldl + -lrt + -Wl,--no-as-needed + -fPIC + -fPIC + -lpthread + -lrt + -ldl +) +target_sources(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp +) +set_property( + TARGET + ydb-library-yql-core-cbo-ut + PROPERTY + SPLIT_FACTOR + 1 +) +add_yunittest( + NAME + ydb-library-yql-core-cbo-ut + TEST_TARGET + ydb-library-yql-core-cbo-ut + TEST_ARG + --print-before-suite + --print-before-test + --fork-tests + --print-times + --show-fails +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + LABELS + SMALL +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + PROCESSORS + 1 +) +target_allocator(ydb-library-yql-core-cbo-ut + cpp-malloc-jemalloc +) +vcs_info(ydb-library-yql-core-cbo-ut) diff --git a/ydb/library/yql/core/cbo/ut/CMakeLists.linux-x86_64.txt b/ydb/library/yql/core/cbo/ut/CMakeLists.linux-x86_64.txt new file mode 100644 index 00000000000..6e505912d7f --- /dev/null +++ b/ydb/library/yql/core/cbo/ut/CMakeLists.linux-x86_64.txt @@ -0,0 +1,72 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_executable(ydb-library-yql-core-cbo-ut) +target_include_directories(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo +) +target_link_libraries(ydb-library-yql-core-cbo-ut PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + library-cpp-cpuid_check + cpp-testing-unittest_main + yql-core-cbo +) +target_link_options(ydb-library-yql-core-cbo-ut PRIVATE + -ldl + -lrt + -Wl,--no-as-needed + -fPIC + -fPIC + -lpthread + -lrt + -ldl +) +target_sources(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp +) +set_property( + TARGET + ydb-library-yql-core-cbo-ut + PROPERTY + SPLIT_FACTOR + 1 +) +add_yunittest( + NAME + ydb-library-yql-core-cbo-ut + TEST_TARGET + ydb-library-yql-core-cbo-ut + TEST_ARG + --print-before-suite + --print-before-test + --fork-tests + --print-times + --show-fails +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + LABELS + SMALL +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + PROCESSORS + 1 +) +target_allocator(ydb-library-yql-core-cbo-ut + cpp-malloc-tcmalloc + libs-tcmalloc-no_percpu_cache +) +vcs_info(ydb-library-yql-core-cbo-ut) diff --git a/ydb/library/yql/core/cbo/ut/CMakeLists.txt b/ydb/library/yql/core/cbo/ut/CMakeLists.txt new file mode 100644 index 00000000000..f8b31df0c11 --- /dev/null +++ b/ydb/library/yql/core/cbo/ut/CMakeLists.txt @@ -0,0 +1,17 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-aarch64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin-x86_64.txt) +elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) + include(CMakeLists.windows-x86_64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-x86_64.txt) +endif() diff --git a/ydb/library/yql/core/cbo/ut/CMakeLists.windows-x86_64.txt b/ydb/library/yql/core/cbo/ut/CMakeLists.windows-x86_64.txt new file mode 100644 index 00000000000..58b272fdf68 --- /dev/null +++ b/ydb/library/yql/core/cbo/ut/CMakeLists.windows-x86_64.txt @@ -0,0 +1,60 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_executable(ydb-library-yql-core-cbo-ut) +target_include_directories(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo +) +target_link_libraries(ydb-library-yql-core-cbo-ut PUBLIC + contrib-libs-cxxsupp + yutil + library-cpp-cpuid_check + cpp-testing-unittest_main + yql-core-cbo +) +target_sources(ydb-library-yql-core-cbo-ut PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/cbo/cbo_optimizer_ut.cpp +) +set_property( + TARGET + ydb-library-yql-core-cbo-ut + PROPERTY + SPLIT_FACTOR + 1 +) +add_yunittest( + NAME + ydb-library-yql-core-cbo-ut + TEST_TARGET + ydb-library-yql-core-cbo-ut + TEST_ARG + --print-before-suite + --print-before-test + --fork-tests + --print-times + --show-fails +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + LABELS + SMALL +) +set_yunittest_property( + TEST + ydb-library-yql-core-cbo-ut + PROPERTY + PROCESSORS + 1 +) +target_allocator(ydb-library-yql-core-cbo-ut + system_allocator +) +vcs_info(ydb-library-yql-core-cbo-ut) diff --git a/ydb/library/yql/core/cbo/ut/ya.make b/ydb/library/yql/core/cbo/ut/ya.make new file mode 100644 index 00000000000..1bcd687b087 --- /dev/null +++ b/ydb/library/yql/core/cbo/ut/ya.make @@ -0,0 +1,13 @@ +UNITTEST_FOR(ydb/library/yql/core/cbo) + +SRCS( + cbo_optimizer_ut.cpp +) + +PEERDIR( + ydb/library/yql/core/cbo +) + +SIZE(SMALL) + +END() diff --git a/ydb/library/yql/core/cbo/ya.make b/ydb/library/yql/core/cbo/ya.make index fff500f8538..0407284952a 100644 --- a/ydb/library/yql/core/cbo/ya.make +++ b/ydb/library/yql/core/cbo/ya.make @@ -8,3 +8,7 @@ PEERDIR( END() +RECURSE_FOR_TESTS( + ut +) + diff --git a/ydb/library/yql/sql/pg/optimizer_ut.cpp b/ydb/library/yql/sql/pg/optimizer_ut.cpp index d3dd5166d00..17eabdfc72b 100644 --- a/ydb/library/yql/sql/pg/optimizer_ut.cpp +++ b/ydb/library/yql/sql/pg/optimizer_ut.cpp @@ -185,81 +185,4 @@ Y_UNIT_TEST(PgJoinSearch3Rels) { UNIT_ASSERT_STRINGS_EQUAL(expected, resStr); } -Y_UNIT_TEST(InputToString) { - IOptimizer::TRel rel1 = {100000, 1000000, {{'a'}}}; - IOptimizer::TRel rel2 = {1000000, 9000009, {{'b'}}}; - IOptimizer::TRel rel3 = {10000, 9009, {{'c'}}}; - IOptimizer::TInput input = {{rel1, rel2, rel3}}; - - input.EqClasses.emplace_back(IOptimizer::TEq { - {{1, 1}, {2, 1}, {3, 1}} - }); - - auto str = input.ToString(); - - TString expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, -{rows: 1000000,cost: 9000009,vars: [b]}, -{rows: 10000,cost: 9009,vars: [c]}] -EqClasses: [[a,b,c]] -)__"; - UNIT_ASSERT_STRINGS_EQUAL(expected, str); -} - -Y_UNIT_TEST(InputNormalize) { - IOptimizer::TRel rel1 = {100000, 1000000, {{'a'}}}; - IOptimizer::TRel rel2 = {1000000, 9000009, {{'b'}}}; - IOptimizer::TRel rel3 = {10000, 9009, {{'c'}}}; - IOptimizer::TInput input = {{rel1, rel2, rel3}}; - - input.EqClasses.emplace_back(IOptimizer::TEq { - {{1, 1}, {2, 1}} - }); - input.EqClasses.emplace_back(IOptimizer::TEq { - {{2, 1}, {3, 1}} - }); - - TString expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, -{rows: 1000000,cost: 9000009,vars: [b]}, -{rows: 10000,cost: 9009,vars: [c]}] -EqClasses: [[a,b],[b,c]] -)__"; - UNIT_ASSERT_STRINGS_EQUAL(expected, input.ToString()); - - input.Normalize(); - - expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, -{rows: 1000000,cost: 9000009,vars: [b]}, -{rows: 10000,cost: 9009,vars: [c]}] -EqClasses: [[a,b,c]] -)__"; - UNIT_ASSERT_STRINGS_EQUAL(expected, input.ToString()); - - IOptimizer::TRel rel4 = {10001, 9009, {{'d'}}}; - IOptimizer::TInput input2 = {{rel1, rel2, rel3, rel4}}; - input2.EqClasses.emplace_back(IOptimizer::TEq { - {{1, 1}, {2, 1}} - }); - input2.EqClasses.emplace_back(IOptimizer::TEq { - {{4, 1}, {3, 1}} - }); - - expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, -{rows: 1000000,cost: 9000009,vars: [b]}, -{rows: 10000,cost: 9009,vars: [c]}, -{rows: 10001,cost: 9009,vars: [d]}] -EqClasses: [[a,b],[d,c]] -)__"; - UNIT_ASSERT_STRINGS_EQUAL(expected, input2.ToString()); - - input2.Normalize(); - - expected = R"__(Rels: [{rows: 100000,cost: 1000000,vars: [a]}, -{rows: 1000000,cost: 9000009,vars: [b]}, -{rows: 10000,cost: 9009,vars: [c]}, -{rows: 10001,cost: 9009,vars: [d]}] -EqClasses: [[a,b],[c,d]] -)__"; - UNIT_ASSERT_STRINGS_EQUAL(expected, input2.ToString()); -} - } // Y_UNIT_TEST_SUITE(PgOptimizer) |