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

Add support for polling #90

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matthewwardrop
Copy link

@matthewwardrop matthewwardrop commented Oct 17, 2019

This PR adds support for polling the status of presto queries, decoupling it from collection of results (fixing #63). Apologies on taking so long to get to it... life / etc.

Changes:

  • Removed PrestoResult and merged its functionality with PrestoQuery. Keeping both led to some weird logic loops as each tried to keep the other up to date once polling was added.
  • Made PrestoQuery.fetch a private method PrestoQuery._fetch, since calling it directly leads to the iterator not being in sync.
  • Made the PrestoQuery object cache the query results, otherwise there is some weird behaviour whereby if you stop iterating over the rows, you throw away all of the rows left over in the last retrieved chunk.
  • Switched the fetchone / fetchmany relationship so that fetchone is a special case of fetchmany (because the changes above allow multiple iterators to be created over time, so long as there is only one at time, and in this way we don't create a new generator for every row).
  • Added the standard Python .gitignore template provided by GitHub.

I have tested this against a presto cluster, and it works nicely for me. The unit tests appear to be failing for some reason, but I'm not convinced it is caused by this patch.

@matthewwardrop
Copy link
Author

@ggreg @akhandev fyi

@mik-laj
Copy link

mik-laj commented Mar 12, 2020

Any progress with this PR? I would like to use it in the Apache Airflow project.

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