-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement REST API for remote functions #23687
Implement REST API for remote functions #23687
Conversation
5d88dbc
to
6efefeb
Compare
7203526
to
f05ea00
Compare
74cddc6
to
cf23586
Compare
cf23586
to
5e5abbe
Compare
presto-main/pom.xml
Outdated
@@ -436,7 +436,6 @@ | |||
<dependency> | |||
<groupId>com.facebook.presto</groupId> | |||
<artifactId>presto-thrift-api</artifactId> | |||
<scope>test</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: lets move this above line 384 so it's out of the testing section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Jacob. Moved
presto-main/pom.xml
Outdated
@@ -466,7 +465,6 @@ | |||
<dependency> | |||
<groupId>com.facebook.presto</groupId> | |||
<artifactId>presto-function-namespace-managers</artifactId> | |||
<scope>test</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: lets move this above line 384 so it's out of the testing section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
5e5abbe
to
bb4001b
Compare
bb4001b
to
bb11659
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add namespace manager to retrieve REST function signatures.
❓
.setUri(uri) | ||
.build(); | ||
|
||
StatusResponseHandler.StatusResponse response = httpClient.execute(request, StatusResponseHandler.createStatusResponseHandler()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please static import createStatusResponseHandler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
...managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestBasedFunctionApis.java
Show resolved
Hide resolved
} | ||
return version; | ||
} | ||
catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's an IOException, let it bubble up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not. Removed the exception for missing ETag.
latestFunctions.clear(); | ||
UdfFunctionSignatureMap udfFunctionSignatureMap = restApis.getAllFunctions(); | ||
if (udfFunctionSignatureMap == null || udfFunctionSignatureMap.isEmpty()) { | ||
return Collections.emptyList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImmutableList.of()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
|
||
public class RestBasedFunctionNamespaceManagerConfig | ||
{ | ||
private String restUrl = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the default null, to indicate it's a mandatory config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
private RestBasedFunctionNamespaceManager functionNamespaceManager; | ||
public static final String TEST_CATALOG = "unittest"; | ||
public static final URI REST_SERVER_URI = URI.create("http://127.0.0.1:1122"); | ||
TestingFunctionResource resource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing visibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
bb11659
to
eb021e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduce REST based Function Namespace Manager
this.functionSignatureMapJsonCodec = nativeFunctionSignatureMapJsonCodec; | ||
this.httpClient = httpClient; | ||
this.managerConfig = managerConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add requireNonNull
for all inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
private static final Logger log = Logger.get(RestBasedFunctionNamespaceManager.class); | ||
private final RestBasedFunctionApis restApis; | ||
private final List<SqlInvokedFunction> latestFunctions = new ArrayList<>(); | ||
private Optional<String> cachedETag = Optional.empty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be an AtomicReference
, since it's updated concurrently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected. Used AtomicReference
.
|
||
private URI getExecutionEndpoint(SqlFunctionId functionId, String functionVersion) | ||
{ | ||
if (restBasedFunctionNamespaceManagerConfig.getRestUrl() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the getter is annotated with @NotNull, I believe this is pre-validated and you can skip this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@Override | ||
public SqlFunctionResult handle(Request request, Response response) | ||
{ | ||
if (response.getStatusCode() == 404) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search the codebase for constants representing these HTTP error codes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used HTTP error codes in java.net.
{ | ||
this.functionSignatureMapJsonCodec = requireNonNull(nativeFunctionSignatureMapJsonCodec, "nativeFunctionSignatureMapJsonCodec is null"); | ||
this.httpClient = requireNonNull(httpClient, "httpClient is null"); | ||
this.managerConfig = requireNonNull(managerConfig, "httpClient is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.managerConfig = requireNonNull(managerConfig, "httpClient is null"); | |
this.managerConfig = requireNonNull(managerConfig, "managerConfig is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed managerConfig
.../main/java/com/facebook/presto/functionNamespace/rest/RestBasedFunctionNamespaceManager.java
Outdated
Show resolved
Hide resolved
return latestFunctions; | ||
} | ||
|
||
private void createSqlInvokedFunctions(UdfFunctionSignatureMap udfFunctionSignatureMap, List<SqlInvokedFunction> functionList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you have this return the list of functions, and merge the output caller side? Rather than mutating the funcionList
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected. Returned list of functions.
...nagers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java
Outdated
Show resolved
Hide resolved
presto-main/pom.xml
Outdated
<configuration> | ||
<finalName>presto-function-server-executable</finalName> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reference function server is package as presto-function-server-executable
and executed in parallel to presto server launcher. Could you please refer the PR for e2e testing https://github.com/prestodb/presto/pull/23777/files#diff-4f5cabe26761257a4d685a6edc7a43e0fe0f78762f50eeb48530f2bd3b3ee7caR5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. We will add function server executable in subsequent PR.
6b81999
to
23f69f4
Compare
007d089
to
9e96957
Compare
presto-spark-base/pom.xml
Outdated
@@ -265,7 +265,6 @@ | |||
<dependency> | |||
<groupId>com.facebook.presto</groupId> | |||
<artifactId>presto-function-namespace-managers</artifactId> | |||
<scope>test</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentionally removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted. No required now, as FunctionServer
is moved to new maven module presto-function-server
. This change was done to use presto-function-namespace-managers
in thepresto-main
for the FunctionServer
.
<artifactId>jackson-datatype-jdk8</artifactId> | ||
</dependency> | ||
|
||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It is required for presto-function-namespace-managers. Throws undeclared dependency error if removed.
[INFO] --- maven-dependency-plugin:3.1.1:analyze-only (default) @ presto-function-namespace-managers ---
[WARNING] Used undeclared dependencies found:
[WARNING] com.facebook.drift:drift-transport-netty:jar:1.40:compile
63bdd7d
to
1d3518b
Compare
presto-function-server/pom.xml
Outdated
<executions> | ||
<execution> | ||
<id>modernizer</id> | ||
<phase>none</phase> <!-- This disables the plugin --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to disable it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabled and reused existing src/modernizer/violations.xml. Previously disabled due to missing file.
@@ -136,7 +136,39 @@ public SqlInvokedFunction( | |||
throw new IllegalArgumentException("aggregationMetadata must be present for aggregation functions and absent otherwise"); | |||
} | |||
} | |||
public SqlInvokedFunction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks mostly copied from the constructor above. Can they be consolidated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected. Refactored to consolidate shared logic.
5efdedd
to
44d6eb2
Compare
44d6eb2
to
464406a
Compare
464406a
to
36fde3a
Compare
@@ -1509,6 +1509,8 @@ struct JsonBasedUdfFunctionMetadata { | |||
String schema = {}; | |||
RoutineCharacteristics routineCharacteristics = {}; | |||
std::shared_ptr<AggregationFunctionMetadata> aggregateMetadata = {}; | |||
std::shared_ptr<SqlFunctionId> functionId = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question, did you create the h and cpp files by running the generator or did you manually add these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abevk2023 : Did you follow the instructions at https://github.com/prestodb/presto/tree/master/presto-native-execution/presto_cpp/presto_protocol#presto-native-worker-protocol-code-generation to generate this code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I have followed the same instructions to generate the code.
36fde3a
to
6ebe86c
Compare
Co-authored-by: Jacob Khaliqi <[email protected]>
6ebe86c
to
4a71933
Compare
It seems the Thanks to @czentgr who ran the same code in another branch and was able to run it on a runner which has the expected 15GB of space, proving this is not related to the code in this PR: https://github.com/prestodb/presto/actions/runs/13054091353/job/36420794542 |
Implements RFC-0007-remote-functions