presto-python-client icon indicating copy to clipboard operation
presto-python-client copied to clipboard

Add support for polling

Open matthewwardrop opened this issue 5 years ago • 2 comments

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 avatar Oct 17 '19 21:10 matthewwardrop

@ggreg @akhandev fyi

matthewwardrop avatar Oct 17 '19 21:10 matthewwardrop

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

mik-laj avatar Mar 12 '20 19:03 mik-laj