From 78e96ff05d40e29bc3208830a66e88e8b7b062fb Mon Sep 17 00:00:00 2001 From: Zhen Li <10524738+zhli1142015@users.noreply.github.com> Date: Tue, 4 Jul 2023 10:57:21 +0800 Subject: [PATCH] Refactor spark window function folder (#348) --- velox/functions/sparksql/CMakeLists.txt | 1 - .../functions/sparksql/window/CMakeLists.txt | 3 ++- .../{windows => window}/RowNumber.cpp | 4 +-- .../sparksql/{windows => window}/RowNumber.h | 4 +-- .../window/WindowFunctionsRegistration.cpp | 2 ++ .../functions/sparksql/windows/CMakeLists.txt | 22 ---------------- velox/functions/sparksql/windows/Register.cpp | 25 ------------------- velox/functions/sparksql/windows/Register.h | 22 ---------------- 8 files changed, 8 insertions(+), 75 deletions(-) rename velox/functions/sparksql/{windows => window}/RowNumber.cpp (95%) rename velox/functions/sparksql/{windows => window}/RowNumber.h (85%) delete mode 100644 velox/functions/sparksql/windows/CMakeLists.txt delete mode 100644 velox/functions/sparksql/windows/Register.cpp delete mode 100644 velox/functions/sparksql/windows/Register.h diff --git a/velox/functions/sparksql/CMakeLists.txt b/velox/functions/sparksql/CMakeLists.txt index 153af1caea3b..c4cda7c8d975 100644 --- a/velox/functions/sparksql/CMakeLists.txt +++ b/velox/functions/sparksql/CMakeLists.txt @@ -51,7 +51,6 @@ add_subdirectory(window) if(${VELOX_ENABLE_AGGREGATES}) add_subdirectory(aggregates) - add_subdirectory(windows) endif() if(${VELOX_BUILD_TESTING}) diff --git a/velox/functions/sparksql/window/CMakeLists.txt b/velox/functions/sparksql/window/CMakeLists.txt index f79546442d79..742299a27b53 100644 --- a/velox/functions/sparksql/window/CMakeLists.txt +++ b/velox/functions/sparksql/window/CMakeLists.txt @@ -11,7 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -add_library(velox_functions_spark_window WindowFunctionsRegistration.cpp) +add_library(velox_functions_spark_window RowNumber.cpp + WindowFunctionsRegistration.cpp) target_link_libraries(velox_functions_spark_window velox_buffer velox_exec velox_functions_window Folly::folly) diff --git a/velox/functions/sparksql/windows/RowNumber.cpp b/velox/functions/sparksql/window/RowNumber.cpp similarity index 95% rename from velox/functions/sparksql/windows/RowNumber.cpp rename to velox/functions/sparksql/window/RowNumber.cpp index e0e2e82ab9fe..ee099fd21df2 100644 --- a/velox/functions/sparksql/windows/RowNumber.cpp +++ b/velox/functions/sparksql/window/RowNumber.cpp @@ -19,7 +19,7 @@ #include "velox/expression/FunctionSignature.h" #include "velox/vector/FlatVector.h" -namespace facebook::velox::functions::sparksql::windows { +namespace facebook::velox::functions::window::sparksql { namespace { @@ -73,4 +73,4 @@ void registerRowNumber(const std::string& name) { return std::make_unique(); }); } -} // namespace facebook::velox::functions::sparksql::windows +} // namespace facebook::velox::functions::window::sparksql diff --git a/velox/functions/sparksql/windows/RowNumber.h b/velox/functions/sparksql/window/RowNumber.h similarity index 85% rename from velox/functions/sparksql/windows/RowNumber.h rename to velox/functions/sparksql/window/RowNumber.h index 3a70059adc36..55271471981a 100644 --- a/velox/functions/sparksql/windows/RowNumber.h +++ b/velox/functions/sparksql/window/RowNumber.h @@ -17,6 +17,6 @@ #include -namespace facebook::velox::functions::sparksql::windows { +namespace facebook::velox::functions::window::sparksql { void registerRowNumber(const std::string& prefix); -} // namespace facebook::velox::functions::sparksql::windows +} // namespace facebook::velox::functions::window::sparksql diff --git a/velox/functions/sparksql/window/WindowFunctionsRegistration.cpp b/velox/functions/sparksql/window/WindowFunctionsRegistration.cpp index f71a9260de10..c6c43c74c58c 100644 --- a/velox/functions/sparksql/window/WindowFunctionsRegistration.cpp +++ b/velox/functions/sparksql/window/WindowFunctionsRegistration.cpp @@ -15,11 +15,13 @@ */ #include "velox/functions/sparksql/window/WindowFunctionsRegistration.h" #include "velox/functions/lib/window/NthValue.h" +#include "velox/functions/sparksql/window/RowNumber.h" namespace facebook::velox::functions::window::sparksql { void registerWindowFunctions(const std::string& prefix) { functions::window::registerIntegerNthValue(prefix + "nth_value"); + registerRowNumber(prefix + "row_number"); } } // namespace facebook::velox::functions::window::sparksql diff --git a/velox/functions/sparksql/windows/CMakeLists.txt b/velox/functions/sparksql/windows/CMakeLists.txt deleted file mode 100644 index 13887cf68408..000000000000 --- a/velox/functions/sparksql/windows/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -add_library(velox_functions_spark_windows - RowNumber.cpp Register.cpp) - -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - add_compile_options(-Wno-stringop-overflow) -endif() - -target_link_libraries(velox_functions_spark_windows velox_buffer velox_exec - ${FOLLY_WITH_DEPENDENCIES}) \ No newline at end of file diff --git a/velox/functions/sparksql/windows/Register.cpp b/velox/functions/sparksql/windows/Register.cpp deleted file mode 100644 index e2b8f2ea56e7..000000000000 --- a/velox/functions/sparksql/windows/Register.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "velox/functions/sparksql/windows/Register.h" -#include "velox/functions/sparksql/windows/RowNumber.h" - -namespace facebook::velox::functions::sparksql::windows { - -void registerWindowFunctions(const std::string& prefix) { - windows::registerRowNumber(prefix + "row_number"); -} -} // namespace facebook::velox::functions::sparksql::windows diff --git a/velox/functions/sparksql/windows/Register.h b/velox/functions/sparksql/windows/Register.h deleted file mode 100644 index 02635cc3da1a..000000000000 --- a/velox/functions/sparksql/windows/Register.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include - -namespace facebook::velox::functions::sparksql::windows { -void registerWindowFunctions(const std::string& prefix); -} // namespace facebook::velox::functions::sparksql::windows