misc: Add method comments and update docs for distributed procedures#26890
Merged
hantangwangd merged 1 commit intoprestodb:masterfrom Jan 10, 2026
Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates distributed procedure documentation to match the current interface and adds clarifying JavaDoc for key lifecycle methods in DistributedProcedure, including context creation and execution phases. Sequence diagram for distributed procedure execution lifecyclesequenceDiagram
actor Client
participant PrestoCoordinator
participant ConnectorMetadata
participant DistributedProcedure
participant WorkerTasks
Client->>PrestoCoordinator: invoke distributed procedure
PrestoCoordinator->>ConnectorMetadata: get DistributedProcedure
ConnectorMetadata-->>PrestoCoordinator: DistributedProcedure instance
PrestoCoordinator->>DistributedProcedure: createContext(arguments)
DistributedProcedure-->>PrestoCoordinator: ConnectorProcedureContext
PrestoCoordinator->>ConnectorMetadata: bind ConnectorProcedureContext
PrestoCoordinator->>DistributedProcedure: begin(session, procedureContext, tableLayoutHandle, arguments)
DistributedProcedure-->>PrestoCoordinator: ConnectorDistributedProcedureHandle
PrestoCoordinator->>WorkerTasks: execute distributed work using procedureHandle
WorkerTasks-->>PrestoCoordinator: Collection<Slice> fragments
PrestoCoordinator->>DistributedProcedure: finish(session, procedureContext, procedureHandle, fragments)
DistributedProcedure-->>PrestoCoordinator: commit complete
PrestoCoordinator-->>Client: procedure completed
Class diagram for DistributedProcedure lifecycle methodsclassDiagram
class DistributedProcedure {
<<abstract>>
-DistributedProcedureType type
+DistributedProcedureType getType()
+ConnectorDistributedProcedureHandle begin(ConnectorSession session, ConnectorProcedureContext procedureContext, ConnectorTableLayoutHandle tableLayoutHandle, Object[] arguments)
+void finish(ConnectorSession session, ConnectorProcedureContext procedureContext, ConnectorDistributedProcedureHandle procedureHandle, Collection~Slice~ fragments)
+ConnectorProcedureContext createContext(Object[] arguments)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The new Javadoc comments for
beginandfinishshould be updated to end with periods and use consistent verb tense/style (e.g., "Performs preparatory work..." vs "Perform the preparatory work...") to match the rest of the codebase’s Javadoc conventions. - Consider referencing the method names in comments with
{@code begin()}/{@code finish()}(or{@link #begin(...)}/{@link #finish(...)}) in thecreateContextJavadoc so that tooling can correctly link them and the text is clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new Javadoc comments for `begin` and `finish` should be updated to end with periods and use consistent verb tense/style (e.g., "Performs preparatory work..." vs "Perform the preparatory work...") to match the rest of the codebase’s Javadoc conventions.
- Consider referencing the method names in comments with `{@code begin()}`/`{@code finish()}` (or `{@link #begin(...)}`/`{@link #finish(...)}`) in the `createContext` Javadoc so that tooling can correctly link them and the text is clearer.
## Individual Comments
### Comment 1
<location> `presto-spi/src/main/java/com/facebook/presto/spi/procedure/DistributedProcedure.java:47-55` </location>
<code_context>
- public ConnectorProcedureContext createContext()
+ public ConnectorProcedureContext createContext(Object... arguments);
/**
* Performs the preparatory work required when starting the execution of this distributed procedure
</code_context>
<issue_to_address>
**suggestion:** Clarify what the returned handle from `begin` represents and its lifecycle.
The Javadoc for `begin` describes the preparatory work but not what the returned `ConnectorDistributedProcedureHandle` is contractually supposed to represent or how it should be used (e.g., whether it must be passed unchanged to `finish`, whether it needs to be stable/serializable). Please add a brief note on its semantics and lifecycle to make the API contract clearer for connector authors.
```suggestion
/**
* Performs the preparatory work required when starting the execution of this distributed procedure.
* <p>
* The returned {@link ConnectorDistributedProcedureHandle} represents the logical execution of a single
* invocation of this distributed procedure. It:
* <ul>
* <li>MUST be passed, unchanged, to {@link #finish(ConnectorSession, ConnectorProcedureContext, ConnectorDistributedProcedureHandle, Collection)}.</li>
* <li>MUST be stable for the lifetime of that invocation (i.e., identifies one specific run of the procedure).</li>
* <li>SHOULD be serializable and safe to use across tasks or nodes if the implementation needs to reference it in distributed execution.</li>
* </ul>
* Implementations may encode connector-specific state in the handle, but must treat it as an opaque token
* from the perspective of callers.
*/
public abstract ConnectorDistributedProcedureHandle begin(ConnectorSession session, ConnectorProcedureContext procedureContext, ConnectorTableLayoutHandle tableLayoutHandle, Object[] arguments);
/**
* Performs the work required for the final centralized commit, after all distributed execution tasks have
* completed for a single invocation of this distributed procedure.
* <p>
* The {@code procedureHandle} passed here is the same handle returned from {@link #begin(ConnectorSession,
* ConnectorProcedureContext, ConnectorTableLayoutHandle, Object[])} and identifies the procedure invocation
* whose fragments are being finalized.
*/
public abstract void finish(ConnectorSession session, ConnectorProcedureContext procedureContext, ConnectorDistributedProcedureHandle procedureHandle, Collection<Slice> fragments);
```
</issue_to_address>
### Comment 2
<location> `presto-docs/src/main/sphinx/develop/procedures.rst:428` </location>
<code_context>
- IcebergProcedureContext::new);
+ ((session, procedureContext, tableHandle, fragments) -> finishCallDistributedProcedure(session, (IcebergProcedureContext) procedureContext, tableHandle, fragments)),
+ arguments -> {
+ checkArgument(arguments.length == 2, "invalid arguments count: " + arguments.length);
+ checkArgument(arguments[0] instanceof Table && arguments[1] instanceof Transaction, "Invalid arguments, required: [Table, Transaction]");
+ return new IcebergProcedureContext((Table) arguments[0], (Transaction) arguments[1]);
</code_context>
<issue_to_address>
**suggestion (typo):** Consider correcting the error message to use "argument count" instead of "arguments count".
"invalid arguments count" is ungrammatical. Please change it to "invalid argument count" or "invalid number of arguments" for clearer messaging.
```suggestion
checkArgument(arguments.length == 2, "invalid argument count: " + arguments.length);
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
presto-spi/src/main/java/com/facebook/presto/spi/procedure/DistributedProcedure.java
Show resolved
Hide resolved
12bf780 to
09b4967
Compare
steveburnett
approved these changes
Jan 8, 2026
Contributor
steveburnett
left a comment
There was a problem hiding this comment.
LGTM! (docs)
Pull branch, local doc build, looks great. Thank you!
tdcmeehan
approved these changes
Jan 10, 2026
tdcmeehan
pushed a commit
to rdtr/presto
that referenced
this pull request
Jan 14, 2026
…restodb#26890) ## Description This PR updates the procedure development documentation to align with the interface and implementation logic adjustments in the distributed procedure code, and adds comments to some abstract methods in class `DistributedProcedure`. ## Motivation and Context Ensures the procedure development documentation more accurate. ## Impact N/A ## Test Plan N/A ## Contributor checklist - [ ] 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). - [ ] PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced. - [ ] Documented new properties (with its default value), SQL syntax, functions, or other functionality. - [ ] If release notes are required, they follow the [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines). - [ ] Adequate tests were added if applicable. - [ ] CI passed. - [ ] If adding new dependencies, verified they have an [OpenSSF Scorecard](https://securityscorecards.dev/#the-checks) score of 5.0 or higher (or obtained explicit TSC approval for lower scores). ## Release Notes ``` == NO RELEASE NOTE == ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR updates the procedure development documentation to align with the interface and implementation logic adjustments in the distributed procedure code, and adds comments to some abstract methods in class
DistributedProcedure.Motivation and Context
Ensures the procedure development documentation more accurate.
Impact
N/A
Test Plan
N/A
Contributor checklist
Release Notes