Add a Task system along the existing statements #488
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.
What changes were proposed in this pull request?
This PR introduces a Task system alongside the existing Statement mechanism.
The goal is to provide an API that behaves similarly to statements but supports retrieving job results even after completion, which is particularly useful when Livy is used by scalable backend applications where the original request context may no longer exist once the job finishes.
How is this different from the existing Job API?
The current Job API is primarily an internal mechanism, mainly used for operations such as driver pings or adding JARs. It’s also leveraged by the Java/Scala clients, even though the endpoint itself is not officially documented. Moreover, jobs managed through this API are handled solely by the server and may execute on the same thread as Netty.
In contrast, the new Task API is an official public API for running serialized jobs from native Java/Scala applications within the same isolated driver environment as statements.
Tasks are fully managed by the session on the driver side and follow the same lifecycle and garbage collection policies as statements. Additionally, the API exposes progress information and other metadata similar to what’s available for statements.
While the Job API is a one-shot mechanism (the job is destroyed as soon as its result is fetched), the Task API supports multiple result fetches, making it more suitable for scalable, asynchronous systems.
How was this patch tested?
This change was validated through unit tests and integration testing within our production environment.