Skip to content

Commit

Permalink
[native] Add expression optimization support in sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsatya committed Dec 2, 2024
1 parent 8ea5aea commit 10bfc08
Show file tree
Hide file tree
Showing 14 changed files with 1,639 additions and 24 deletions.
2 changes: 2 additions & 0 deletions presto-native-execution/presto_cpp/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_subdirectory(operators)
add_subdirectory(types)
add_subdirectory(http)
add_subdirectory(common)
add_subdirectory(expression)
add_subdirectory(thrift)

add_library(
Expand Down Expand Up @@ -50,6 +51,7 @@ target_link_libraries(
presto_function_metadata
presto_http
presto_operators
presto_expression_optimizer
velox_aggregates
velox_caching
velox_common_base
Expand Down
10 changes: 10 additions & 0 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,16 @@ void PrestoServer::registerSidecarEndpoints() {
proxygen::ResponseHandler* downstream) {
http::sendOkResponse(downstream, getFunctionsMetadata());
});

rowExpressionOptimizer_ =
std::make_unique<expression::RowExpressionOptimizer>();
httpServer_->registerPost(
"/v1/expressions",
[&](proxygen::HTTPMessage* message,
const std::vector<std::unique_ptr<folly::IOBuf>>& body,
proxygen::ResponseHandler* downstream) {
return rowExpressionOptimizer_->optimize(message, body, downstream);
});
}

protocol::NodeStatus PrestoServer::fetchNodeStatus() {
Expand Down
2 changes: 2 additions & 0 deletions presto-native-execution/presto_cpp/main/PrestoServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "presto_cpp/main/PeriodicHeartbeatManager.h"
#include "presto_cpp/main/PrestoExchangeSource.h"
#include "presto_cpp/main/PrestoServerOperations.h"
#include "presto_cpp/main/expression/RowExpressionOptimizer.h"
#include "presto_cpp/main/types/VeloxPlanValidator.h"
#include "velox/common/caching/AsyncDataCache.h"
#include "velox/common/memory/MemoryAllocator.h"
Expand Down Expand Up @@ -287,6 +288,7 @@ class PrestoServer {
std::string address_;
std::string nodeLocation_;
folly::SSLContextPtr sslContext_;
std::unique_ptr<expression::RowExpressionOptimizer> rowExpressionOptimizer_;
};

} // namespace facebook::presto
32 changes: 32 additions & 0 deletions presto-native-execution/presto_cpp/main/expression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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(presto_expression_optimizer RowExpressionOptimizer.cpp)

target_link_libraries(
presto_expression_optimizer
presto_type_converter
presto_types
presto_protocol
presto_http
velox_coverage_util
velox_parse_expression
velox_parse_parser
velox_presto_serializer
velox_serialization
velox_type_parser
${FOLLY_WITH_DEPENDENCIES})

if(PRESTO_ENABLE_TESTING)
add_subdirectory(tests)
endif()
Loading

0 comments on commit 10bfc08

Please sign in to comment.