airflow.providers.apache.hive.operators.hive_stats

HiveStatsCollectionOperator

收集分区统计信息并将它们插入到 MySQL 中。

模块内容

class airflow.providers.apache.hive.operators.hive_stats.HiveStatsCollectionOperator(*, table, partition, extra_exprs=None, excluded_columns=None, assignment_func=None, metastore_conn_id='metastore_default', presto_conn_id='presto_default', mysql_conn_id='airflow_db', ds='{{ ds }}', dttm='{{ logical_date.isoformat() }}', **kwargs)[source]

基类: airflow.models.BaseOperator

收集分区统计信息并将它们插入到 MySQL 中。

统计信息是通过动态生成的 Presto 查询收集的,并以此格式插入。如果您重新运行相同的日期/分区,统计信息会覆盖自身。

CREATE TABLE hive_stats (
    ds VARCHAR(16),
    table_name VARCHAR(500),
    metric VARCHAR(200),
    value BIGINT
);
参数:
  • metastore_conn_id (str) – 对 Hive Metastore 连接 ID 的引用。

  • table (str) – 源表,格式为 database.table_name。(模板化)

  • partition (Any) – 源分区。(模板化)

  • extra_exprs (dict[str, Any] | None) – 用于针对表运行的表达式字典,其中键是指标名称,值是 Presto 兼容的表达式

  • excluded_columns (list[str] | None) – 要排除的列列表,考虑排除 blobs、大型 json 列等…

  • assignment_func (Callable[[str, str], dict[Any, Any] | None] | None) – 一个接收列名和类型,并返回指标名称和 Presto 表达式字典的函数。如果返回 None,则应用全局默认值。如果返回空字典,则不对该列计算统计信息。

template_fields: collections.abc.Sequence[str] = ('table', 'partition', 'ds', 'dttm')[source]
ui_color = '#aff7a6'[source]
table[source]
partition[source]
extra_exprs[source]
excluded_columns: list[str] = [][source]
metastore_conn_id = 'metastore_default'[source]
presto_conn_id = 'presto_default'[source]
mysql_conn_id = 'airflow_db'[source]
assignment_func = None[source]
ds = '{{ ds }}'[source]
dttm : str = '{{ logical_date.isoformat() }}'[source]
get_default_exprs(col, col_type)[source]

获取默认表达式。

execute(context)[source]

在创建操作符时派生。

Context 与渲染 jinja 模板时使用的字典相同。

有关更多上下文,请参阅 get_template_context。

此条目是否有帮助?