Skip to content

Commit

Permalink
Cleanup window function registry tests (facebookincubator#8057)
Browse files Browse the repository at this point in the history
Summary:
There are two test files for validating window function registration:
1. velox/functions/prestosql/window/tests/WindowFunctionRegTest.cpp
2. velox/exec/tests/WindowFunctionRegistryTest.cpp

This PR moves the tests from 1 into 2, and removes 1. This follows from the
conversation in facebookincubator#7243.

Pull Request resolved: facebookincubator#8057

Reviewed By: kgpai

Differential Revision: D52208891

Pulled By: kagamiori

fbshipit-source-id: 0ce444faa24247cd8d69d12b969b90adce873511
  • Loading branch information
pramodsatya authored and facebook-github-bot committed Dec 15, 2023
1 parent 01756db commit 9cfae32
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 61 deletions.
1 change: 1 addition & 0 deletions velox/exec/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ target_link_libraries(
velox_type
velox_vector
velox_vector_fuzzer
velox_window
Boost::atomic
Boost::context
Boost::date_time
Expand Down
25 changes: 24 additions & 1 deletion velox/exec/tests/WindowFunctionRegistryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "velox/exec/WindowFunction.h"
#include "velox/expression/SignatureBinder.h"
#include "velox/type/Type.h"
#include "velox/functions/prestosql/window/WindowFunctionsRegistration.h"

namespace facebook::velox::exec::test {

Expand Down Expand Up @@ -107,4 +107,27 @@ TEST_F(WindowFunctionRegistryTest, mixedCaseName) {
"window_fUNC_alias", {BIGINT(), DOUBLE()}, BIGINT());
}

TEST_F(WindowFunctionRegistryTest, prefix) {
// Remove all functions and check for no entries.
exec::windowFunctions().clear();
EXPECT_EQ(0, exec::windowFunctions().size());

// Register without prefix and memorize function maps.
window::prestosql::registerAllWindowFunctions();
const auto windowFuncMapBase = exec::windowFunctions();

// Remove all functions and check for no entries.
exec::windowFunctions().clear();
EXPECT_EQ(0, exec::windowFunctions().size());

// Register with prefix and check all functions have the prefix.
const std::string prefix{"test.abc_schema."};
window::prestosql::registerAllWindowFunctions(prefix);
auto& windowFuncMap = exec::windowFunctions();
for (const auto& entry : windowFuncMap) {
EXPECT_EQ(prefix, entry.first.substr(0, prefix.size()));
EXPECT_EQ(1, windowFuncMapBase.count(entry.first.substr(prefix.size())));
}
}

} // namespace facebook::velox::exec::test
11 changes: 0 additions & 11 deletions velox/functions/prestosql/window/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,3 @@ add_test(

target_link_libraries(velox_windows_agg_test
${CMAKE_WINDOW_TEST_LINK_LIBRARIES})

add_executable(velox_windows_util_test WindowFunctionRegTest.cpp
${CMAKE_WINDOW_TEST_MAIN_FILES})

add_test(
NAME velox_windows_util_test
COMMAND velox_windows_util_test
WORKING_DIRECTORY .)

target_link_libraries(velox_windows_util_test
${CMAKE_WINDOW_TEST_LINK_LIBRARIES})
49 changes: 0 additions & 49 deletions velox/functions/prestosql/window/tests/WindowFunctionRegTest.cpp

This file was deleted.

0 comments on commit 9cfae32

Please sign in to comment.