airflow.providers.presto.hooks.presto¶
Attributes¶
Exceptions¶
Presto exception. |
Classes¶
Interact with Presto through prestodb. |
Functions¶
Return json string with dag_id, task_id, logical_date and try_number. |
Module Contents¶
- airflow.providers.presto.hooks.presto.generate_presto_client_info()[source]¶
Return json string with dag_id, task_id, logical_date and try_number.
- exception airflow.providers.presto.hooks.presto.PrestoException[source]¶
Bases:
Exception
Presto exception.
- class airflow.providers.presto.hooks.presto.PrestoHook(*args, **kwargs)[source]¶
Bases:
airflow.providers.common.sql.hooks.sql.DbApiHook
Interact with Presto through prestodb.
>>> ph = PrestoHook() >>> sql = "SELECT count(1) AS num FROM airflow.static_babynames" >>> ph.get_records(sql) [[340698]]
- get_records(sql='', parameters=None)[source]¶
Execute the sql and return a set of records.
- Parameters:
sql (str | list[str]) – the sql statement to be executed (str) or a list of sql statements to execute
parameters (collections.abc.Iterable | collections.abc.Mapping[str, Any] | None) – The parameters to render the SQL query with.
- get_first(sql='', parameters=None)[source]¶
Execute the sql and return the first resulting row.
- Parameters:
sql (str | list[str]) – the sql statement to be executed (str) or a list of sql statements to execute
parameters (collections.abc.Iterable | collections.abc.Mapping[str, Any] | None) – The parameters to render the SQL query with.
- get_pandas_df(sql='', parameters=None, **kwargs)[source]¶
Execute the sql and returns a pandas dataframe.
- Parameters:
sql (str) – the sql statement to be executed (str) or a list of sql statements to execute
parameters – The parameters to render the SQL query with.
kwargs – (optional) passed into pandas.io.sql.read_sql method
- insert_rows(table, rows, target_fields=None, commit_every=0, replace=False, **kwargs)[source]¶
Insert a set of tuples into a table.
- Parameters:
table (str) – Name of the target table
rows (collections.abc.Iterable[tuple]) – The rows to insert into the table
target_fields (collections.abc.Iterable[str] | None) – The names of the columns to fill in the table
commit_every (int) – The maximum number of rows to insert in one transaction. Set to 0 to insert all rows in one transaction.
replace (bool) – Whether to replace instead of insert