Skip to content
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

[ PECO-2065 ] Create the async execution flow for the PySQL Connector #463

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jprakash-db
Copy link
Contributor

@jprakash-db jprakash-db commented Oct 29, 2024

Description

Implementing the flow for the asynchronous execution of the execute command

Functions added

execute_async

This is the main command that will be used to execute the query, otherwise the syntax is identical to the existing execute function

get_query_state

This function is used for the purpose of polling the status of the query, to know what is the status of execution

get_execution_result

This function is used to fetch the results that have been completed and then populate the ResultSet. The flow of handling the ResultSet onwards is the same

Testing Details

Added Integration tests

@jprakash-db jprakash-db self-assigned this Oct 29, 2024
Copy link

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Copy link

github-actions bot commented Nov 2, 2024

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Copy link

github-actions bot commented Nov 2, 2024

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Copy link

github-actions bot commented Nov 4, 2024

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

Copy link

github-actions bot commented Nov 4, 2024

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@@ -733,6 +733,7 @@ def execute(
self,
operation: str,
parameters: Optional[TParameterCollection] = None,
async_op=False,
) -> "Cursor":
"""
Execute a query and wait for execution to complete.
Copy link
Collaborator

@jackyhu-db jackyhu-db Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update the description of the method if it supports async_op or rename this method to private e.g. _execute and keep execute as sync.

@@ -812,6 +815,44 @@ def execute(

return self

def execute_async(
Copy link
Collaborator

@jackyhu-db jackyhu-db Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the method parameter doc and description as execute and include the return type in the method signature

):
return self.execute(operation, parameters, True)

def get_query_state(self):
Copy link
Collaborator

@jackyhu-db jackyhu-db Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the method parameter doc and description as execute and include the return type in the method signature. e.g. -> "TOperationState":

cursor.execute_async(long_running_query)

## Polling
while isExecuting(cursor.get_query_state()):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add polling interval

@@ -1119,7 +1161,7 @@ def __init__(
self._arrow_schema_bytes = execute_response.arrow_schema_bytes
self._next_row_index = 0

if execute_response.arrow_queue:
if execute_response.arrow_queue or async_op:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why async_op depends on arrow? What if pyarrow is not installed

@@ -796,13 +797,15 @@ def execute(
cursor=self,
use_cloud_fetch=self.connection.use_cloud_fetch,
parameters=prepared_params,
async_op=async_op,
)
self.active_result_set = ResultSet(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result set is not ready yet when async_op is True, why do you set this? It should be set in theget_execution_result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants