airflow.providers.trino.hooks.trino

属性

T

异常

TrinoException

Trino 异常。

TrinoHook

通过 trino 包与 Trino 交互。

函数

generate_trino_client_info()

返回包含 dag_id、task_id、logical_date 和 try_number 的 json 字符串。

模块内容

airflow.providers.trino.hooks.trino.T[source]
airflow.providers.trino.hooks.trino.generate_trino_client_info()[source]

返回包含 dag_id、task_id、logical_date 和 try_number 的 json 字符串。

exception airflow.providers.trino.hooks.trino.TrinoException[source]

继承自: Exception

Trino 异常。

class airflow.providers.trino.hooks.trino.TrinoHook(*args, **kwargs)[source]

继承自: airflow.providers.common.sql.hooks.sql.DbApiHook

通过 trino 包与 Trino 交互。

>>> ph = TrinoHook()
>>> sql = "SELECT count(1) AS num FROM airflow.static_babynames"
>>> ph.get_records(sql)
[[340698]]
conn_name_attr = 'trino_conn_id'[source]
default_conn_name = 'trino_default'[source]
conn_type = 'trino'[source]
hook_name = 'Trino'[source]
strip_semicolon = True[source]
query_id = ''[source]
classmethod get_ui_field_behaviour()[source]

返回自定义字段行为。

get_conn()[source]

返回连接对象。

get_isolation_level()[source]

返回隔离级别。

get_records(sql='', parameters=None)[source]

执行 SQL 并返回一组记录。

参数:
get_first(sql='', parameters=None)[source]

执行 SQL 并返回第一个结果行。

参数:
get_pandas_df(sql='', parameters=None, **kwargs)[source]

执行 SQL 并返回一个 pandas 数据框。

参数:
  • sql (str) – 要执行的 SQL 语句(str)或要执行的 SQL 语句列表

  • parameters (collections.abc.Iterable | collections.abc.Mapping[str, Any] | None) – 用于渲染 SQL 查询的参数。

  • kwargs – (可选)传递给 pandas.io.sql.read_sql 方法的参数

insert_rows(table, rows, target_fields=None, commit_every=0, replace=False, **kwargs)[source]

以通用方式将一组元组插入到表中。

参数:
  • table (str) – 目标表的名称

  • rows (collections.abc.Iterable[tuple]) – 要插入到表中的行

  • target_fields (collections.abc.Iterable[str] | None) – 要填充表中列的名称

  • commit_every (int) – 在一个事务中插入的最大行数。设置为 0 表示在一个事务中插入所有行。

  • replace (bool) – 是否替换而不是插入

get_openlineage_database_info(connection)[source]

返回用于 OpenLineage 的 Trino 特定信息。

get_openlineage_database_dialect(_)[source]

返回 Trino 方言。

get_openlineage_default_schema()[source]

返回 Trino 默认 schema。

get_uri()[source]

返回连接的 Trino URI。

此条目有帮助吗?