Skip to content

Commit

Permalink
Update docstring for TD-specific query params
Browse files Browse the repository at this point in the history
  • Loading branch information
takuti committed Sep 5, 2019
1 parent 5278cbd commit eda21b8
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 5 deletions.
19 changes: 19 additions & 0 deletions pytd/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,25 @@ def query(self, query, engine=None, **kwargs):
Query engine. If not given, default query engine created in the
constructor will be used.
**kwargs
Treasure Data-specific optional query parameters. Giving these
keyword arguments forces query engine to issue a query via Treasure
Data REST API provided by ``tdclient``; that is, if ``engine`` is
Presto, you cannot enjoy efficient direct access to the query
engine provided by ``prestodb``.
- ``db`` (str): use the database
- ``result_url`` (str): result output URL
- ``priority`` (int or str): priority
- -2: "VERY LOW"
- -1: "LOW"
- 0: "NORMAL"
- 1: "HIGH"
- 2: "VERY HIGH"
- ``retry_limit`` (int): max number of automatic retries
- ``wait_interval`` (int): sleep interval until job finish
- ``wait_callback`` (function): called every interval against job itself
Returns
-------
dict : keys ('data', 'columns')
Expand Down
21 changes: 16 additions & 5 deletions pytd/pandas_td/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,23 @@ def read_td_query(
See https://prestodb.io/docs/current/release/release-0.77.html
params : dict, optional
Parameters to pass to execute method.
Parameters to pass to execute method. pytd does not support parameter
``type`` ('hive', 'presto'), and query type needs to be defined by
``engine``.
Available parameters:
- result_url (str): result output URL
- priority (int or str): priority (e.g. "NORMAL", "HIGH", etc.)
- retry_limit (int): retry limit
pytd: This argument will be ignored.
- ``db`` (str): use the database
- ``result_url`` (str): result output URL
- ``priority`` (int or str): priority
- -2: "VERY LOW"
- -1: "LOW"
- 0: "NORMAL"
- 1: "HIGH"
- 2: "VERY HIGH"
- ``retry_limit`` (int): max number of automatic retries
- ``wait_interval`` (int): sleep interval until job finish
- ``wait_callback`` (function): called every interval against job itself
Returns
-------
Expand Down
75 changes: 75 additions & 0 deletions pytd/query_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ def execute(self, query, **kwargs):
query : string
Query.
**kwargs
Treasure Data-specific optional query parameters. Giving these
keyword arguments forces query engine to issue a query via Treasure
Data REST API provided by ``tdclient``, rather than using a direct
connection established by the ``prestodb`` package.
- ``db`` (str): use the database
- ``result_url`` (str): result output URL
- ``priority`` (int or str): priority
- -2: "VERY LOW"
- -1: "LOW"
- 0: "NORMAL"
- 1: "HIGH"
- 2: "VERY HIGH"
- ``retry_limit`` (int): max number of automatic retries
- ``wait_interval`` (int): sleep interval until job finish
- ``wait_callback`` (function): called every interval against job itself
Returns
-------
dict : keys ('data', 'columns')
Expand Down Expand Up @@ -125,6 +143,24 @@ def _get_tdclient_cursor(self, con, **kwargs):
con : tdclient.connection.Connection
Handler created by ``tdclient#connect``.
**kwargs
Treasure Data-specific optional query parameters. Giving these
keyword arguments forces query engine to issue a query via Treasure
Data REST API provided by ``tdclient``, rather than using a direct
connection established by the ``prestodb`` package.
- ``db`` (str): use the database
- ``result_url`` (str): result output URL
- ``priority`` (int or str): priority
- -2: "VERY LOW"
- -1: "LOW"
- 0: "NORMAL"
- 1: "HIGH"
- 2: "VERY HIGH"
- ``retry_limit`` (int): max number of automatic retries
- ``wait_interval`` (int): sleep interval until job finish
- ``wait_callback`` (function): called every interval against job itself
Returns
-------
tdclient.cursor.Cursor
Expand Down Expand Up @@ -221,6 +257,26 @@ def presto_api_host(self):
def cursor(self, **kwargs):
"""Get cursor defined by DB-API.
Parameters
----------
**kwargs
Treasure Data-specific optional query parameters. Giving these
keyword arguments forces query engine to issue a query via Treasure
Data REST API provided by ``tdclient``, rather than using a direct
connection established by the ``prestodb`` package.
- ``db`` (str): use the database
- ``result_url`` (str): result output URL
- ``priority`` (int or str): priority
- -2: "VERY LOW"
- -1: "LOW"
- 0: "NORMAL"
- 1: "HIGH"
- 2: "VERY HIGH"
- ``retry_limit`` (int): max number of automatic retries
- ``wait_interval`` (int): sleep interval until job finish
- ``wait_callback`` (function): called every interval against job itself
Returns
-------
prestodb.dbapi.Cursor, or tdclient.cursor.Cursor
Expand Down Expand Up @@ -288,6 +344,25 @@ def user_agent(self):
def cursor(self, **kwargs):
"""Get cursor defined by DB-API.
Parameters
----------
**kwargs
Treasure Data-specific optional query parameters. Giving these
keyword arguments forces query engine to issue a query via Treasure
Data REST API provided by ``tdclient``.
- ``db`` (str): use the database
- ``result_url`` (str): result output URL
- ``priority`` (int or str): priority
- -2: "VERY LOW"
- -1: "LOW"
- 0: "NORMAL"
- 1: "HIGH"
- 2: "VERY HIGH"
- ``retry_limit`` (int): max number of automatic retries
- ``wait_interval`` (int): sleep interval until job finish
- ``wait_callback`` (function): called every interval against job itself
Returns
-------
tdclient.cursor.Cursor
Expand Down

0 comments on commit eda21b8

Please sign in to comment.