airflow.hooks.presto_hook

Module Contents

exception airflow.hooks.presto_hook.PrestoException[source]

Bases: Exception

class airflow.hooks.presto_hook.PrestoHook[source]

Bases: airflow.hooks.dbapi_hook.DbApiHook

Interact with Presto through PyHive!

>>> ph = PrestoHook()
>>> sql = "SELECT count(1) AS num FROM airflow.static_babynames"
>>> ph.get_records(sql)
[[340698]]
conn_name_attr = presto_conn_id[source]
default_conn_name = presto_default[source]
get_conn(self)[source]

Returns a connection object

static _strip_sql(sql)[source]
static _get_pretty_exception_message(e)[source]

Parses some DatabaseError to provide a better error message

get_records(self, hql, parameters=None)[source]

Get a set of records from Presto

get_first(self, hql, parameters=None)[source]

Returns only the first row, regardless of how many rows the query returns.

get_pandas_df(self, hql, parameters=None)[source]

Get a pandas dataframe from a sql query.

run(self, hql, parameters=None)[source]

Execute the statement against Presto. Can be used to create views.

insert_rows(self, table, rows, target_fields=None)[source]

A generic way to insert a set of tuples into a table.

Parameters
  • table (str) – Name of the target table

  • rows (iterable of tuples) – The rows to insert into the table

  • target_fields (iterable of strings) – The names of the columns to fill in the table