Skip to content

Commit d8ee0c1

Browse files
feat(native): Add support for REST based remote function (#23568)
## Description Adds support of REST based remote function to presto native. The following features will be added in the subsequent PRs and is not addressed in this PR - #25334 ## Motivation and Context - Part of #23682 ## Impact - New capability for remote function execution via REST protocol - No changes to existing public APIs or user-facing features - Minimal performance impact as registration is one-time per function location ## Test Plan - Container-based integration tests with embedded function server - Multi-threaded concurrent registration and execution scenarios - HTTP response validation and error handling tests ## Contributor checklist - [x] Please make sure your submission complies with our [contributing guide](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md), in particular [code style](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#code-style) and [commit standards](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-standards). - [x] PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced. - [x] Documented new properties (with its default value), SQL syntax, functions, or other functionality. - [x] If release notes are required, they follow the [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines). - [x] Adequate tests were added if applicable. - [x] CI passed. ## Release Notes ``` == RELEASE NOTES == Prestissimo (Native Execution) Changes * Add support for REST API for Remote Functions in native engine. [RFC-007](https://github.com/prestodb/rfcs/blob/main/RFC-0007-remote-functions.md) ``` Co-authored-by: Wills Feng <[email protected]>
1 parent cd3e3c8 commit d8ee0c1

40 files changed

+2640
-63
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ presto-native-execution/deps-install
6666
# Compiled executables used for docker build
6767
/docker/presto-cli-*-executable.jar
6868
/docker/presto-server-*.tar.gz
69+
/docker/presto-function-server-executable.jar

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM quay.io/centos/centos:stream9
33
ARG PRESTO_VERSION
44
ARG PRESTO_PKG=presto-server-$PRESTO_VERSION.tar.gz
55
ARG PRESTO_CLI_JAR=presto-cli-$PRESTO_VERSION-executable.jar
6+
ARG PRESTO_REMOTE_SERVER_JAR=presto-function-server-executable.jar
67
ARG JMX_PROMETHEUS_JAVAAGENT_VERSION=0.20.0
78

89
ENV PRESTO_HOME="/opt/presto-server"
@@ -13,7 +14,8 @@ RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked \
1314
# clean cache jobs
1415
&& mv /etc/yum/protected.d/systemd.conf /etc/yum/protected.d/systemd.conf.bak
1516

16-
COPY --chmod=755 $PRESTO_CLI_JAR /opt/presto-cli
17+
COPY --chmod=755 $PRESTO_CLI_JAR /opt/presto-cli
18+
COPY --chmod=755 $PRESTO_REMOTE_SERVER_JAR /opt/presto-remote-function-server
1719

1820
RUN --mount=type=bind,source=$PRESTO_PKG,target=/$PRESTO_PKG \
1921
# Download Presto and move \
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore build directories
2+
_build/
3+
cmake-build-debug/
4+
cmake-build-release/

presto-native-execution/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ set(Boost_USE_MULTITHREADED TRUE)
136136
find_package(
137137
Boost
138138
1.66.0
139-
REQUIRED program_options context filesystem regex thread system date_time atomic
139+
REQUIRED program_options context filesystem regex thread system date_time url atomic
140140
)
141141
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
142142

presto-native-execution/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@
503503
<include>presto-cli-*-executable.jar</include>
504504
</includes>
505505
</resource>
506+
<resource>
507+
<directory>${project.parent.basedir}/presto-function-server/target</directory>
508+
<includes>
509+
<include>presto-function-server-executable.jar</include>
510+
</includes>
511+
</resource>
506512
<resource>
507513
<directory>${project.parent.basedir}/presto-server/target</directory>
508514
<includes>
@@ -574,7 +580,7 @@
574580
<args>
575581
<BUILD_TYPE>Release</BUILD_TYPE>
576582
<DEPENDENCY_IMAGE>presto-native-dependency:latest</DEPENDENCY_IMAGE>
577-
<EXTRA_CMAKE_FLAGS>-DPRESTO_ENABLE_TESTING=OFF</EXTRA_CMAKE_FLAGS>
583+
<EXTRA_CMAKE_FLAGS>"-DPRESTO_ENABLE_TESTING=OFF -DPRESTO_ENABLE_REMOTE_FUNCTIONS=ON"</EXTRA_CMAKE_FLAGS>
578584
<NUM_THREADS>2</NUM_THREADS>
579585
<BASE_IMAGE>ubuntu:22.04</BASE_IMAGE>
580586
<OSNAME>ubuntu</OSNAME>

presto-native-execution/presto_cpp/main/PrestoServer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,11 +1391,12 @@ void PrestoServer::registerRemoteFunctions() {
13911391
<< catalogName << "' catalog.";
13921392
} else {
13931393
VELOX_FAIL(
1394-
"To register remote functions using a json file path you need to "
1395-
"specify the remote server location using '{}', '{}' or '{}'.",
1394+
"To register remote functions you need to specify the remote server "
1395+
"location using '{}', '{}' or '{}' or {}.",
13961396
SystemConfig::kRemoteFunctionServerThriftAddress,
13971397
SystemConfig::kRemoteFunctionServerThriftPort,
1398-
SystemConfig::kRemoteFunctionServerThriftUdsPath);
1398+
SystemConfig::kRemoteFunctionServerThriftUdsPath,
1399+
SystemConfig::kRemoteFunctionServerRestURL);
13991400
}
14001401
}
14011402
#endif

presto-native-execution/presto_cpp/main/common/Configs.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ std::string SystemConfig::remoteFunctionServerSerde() const {
480480
return optionalProperty(kRemoteFunctionServerSerde).value();
481481
}
482482

483+
std::string SystemConfig::remoteFunctionServerRestURL() const {
484+
return optionalProperty(kRemoteFunctionServerRestURL).value();
485+
}
486+
483487
int32_t SystemConfig::maxDriversPerTask() const {
484488
return optionalProperty<int32_t>(kMaxDriversPerTask).value();
485489
}

presto-native-execution/presto_cpp/main/common/Configs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,10 @@ class SystemConfig : public ConfigBase {
768768
static constexpr std::string_view kRemoteFunctionServerThriftUdsPath{
769769
"remote-function-server.thrift.uds-path"};
770770

771+
/// HTTP URL used by the remote function rest server.
772+
static constexpr std::string_view kRemoteFunctionServerRestURL{
773+
"remote-function-server.rest.url"};
774+
771775
/// Path where json files containing signatures for remote functions can be
772776
/// found.
773777
static constexpr std::string_view
@@ -929,6 +933,8 @@ class SystemConfig : public ConfigBase {
929933

930934
std::string remoteFunctionServerSerde() const;
931935

936+
std::string remoteFunctionServerRestURL() const;
937+
932938
int32_t maxDriversPerTask() const;
933939

934940
int32_t driverMaxSplitPreload() const;

presto-native-execution/presto_cpp/main/functions/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
# limitations under the License.
1212

1313
add_library(presto_function_metadata OBJECT FunctionMetadata.cpp)
14-
target_link_libraries(presto_function_metadata velox_function_registry)
14+
target_link_libraries(presto_function_metadata presto_common velox_function_registry)
1515

1616
add_subdirectory(dynamic_registry)
1717

18+
if(PRESTO_ENABLE_REMOTE_FUNCTIONS)
19+
add_subdirectory(remote)
20+
endif()
21+
1822
if(PRESTO_ENABLE_TESTING)
1923
add_subdirectory(tests)
2024
endif()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
add_library(presto_to_velox_remote_functions PrestoRestFunctionRegistration.cpp)
14+
target_link_libraries(
15+
presto_to_velox_remote_functions
16+
presto_functions_remote
17+
velox_type_fbhive
18+
Boost::url
19+
)
20+
21+
add_library(presto_functions_remote RestRemoteFunction.cpp)
22+
target_link_libraries(presto_functions_remote presto_functions_rest_client velox_functions_remote)
23+
24+
add_subdirectory(client)
25+
26+
if(${PRESTO_ENABLE_TESTING})
27+
add_subdirectory(tests)
28+
endif()

0 commit comments

Comments
 (0)