presto-python-client
presto-python-client copied to clipboard
Add support for polling
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 withPrestoQuery
. 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 methodPrestoQuery._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 thatfetchone
is a special case offetchmany
(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.
@ggreg @akhandev fyi
Any progress with this PR? I would like to use it in the Apache Airflow project.