Fix issue 102, not do delete requests when query is already finished #152
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.
PR Summary
This PR proposes a potential fix for issue #102
Proposed Solution
Before calling the delete query endpoint, we first validate whether the query has already finished on the Trino side by calling
v1/query/:queryId
. This endpoint returns the query status, and if it returnsFINISHED
, we skip the delete request.Currently, this validation is applied only when
rowIndex = 1
to limit the scope of changes. We can discuss whether it would make sense to always validate the query status before deleting.Discussion Points
Should we validate the status for all cases, not just when rowIndex = 1?
Should we check for both
FINISHED
andFINISHING
states? According to the documentation,FINISHING
indicates that the query has finished executing and all output has been consumed. It may still make sense to call delete forFINISHING
queries since they are still consuming resources.Any idea for integration tests ? Getting the query state while the QueryRow is being run and make sure that the state is never
USER_CANCEL
?