airflow.providers.amazon.aws.operators.athena

AthenaOperator

提交 Trino/Presto 查询到 Amazon Athena 的 Operator。

模块内容

airflow.providers.amazon.aws.operators.athena.AthenaOperator(*, query, database, output_location=None, client_request_token=None, workgroup='primary', query_execution_context=None, result_configuration=None, sleep_time=30, max_polling_attempts=None, log_query=True, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), catalog='AwsDataCatalog', **kwargs)[source]

基类: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.athena.AthenaHook]

提交 Trino/Presto 查询到 Amazon Athena 的 Operator。

注意

如果在任务运行时被杀死,它会取消已启动的 athena 查询,除非在可延迟模式下运行。

另请参阅

有关如何使用此 operator 的更多信息,请参阅指南:在 Amazon Athena 中运行查询

参数::
  • query (str) – 要在 Amazon Athena 上运行的 Trino/Presto 查询。(templated)

  • database (str) – 要选择的数据库。(templated)

  • catalog (str) – 要选择的 Catalog。(templated)

  • output_location (str | None) – 用于写入查询结果的 S3 路径。(templated) 要运行查询,您必须通过以下方式之一指定查询结果位置:使用此设置(客户端)针对单个查询,或在工作组中使用 WorkGroupConfiguration。如果两者都没有设置,Athena 将发出错误,指示未提供输出位置。

  • client_request_token (str | None) – 用户创建的唯一令牌,用于避免多次执行同一个查询。

  • workgroup (str) – 运行查询的 Athena 工作组。(templated)

  • query_execution_context (dict[str, str] | None) – 需要运行查询的上下文。

  • result_configuration (dict[str, Any] | None) – 包含存储结果路径和加密相关配置的字典。

  • sleep_time (int) – 两次连续检查 Athena 查询状态调用之间的等待时间(秒)。

  • max_polling_attempts (int | None) – 函数退出前轮询查询状态的次数。要限制任务执行时间,请使用 execution_timeout。

  • log_query (bool) – 执行 athena 查询及其他执行参数时是否记录日志。默认为 True

  • aws_conn_id – 用于 AWS 凭证的 Airflow 连接。如果此参数为 None 或为空,则使用默认的 boto3 行为。如果在分布式模式下运行 Airflow 并且 aws_conn_id 为 None 或为空,则将使用默认的 boto3 配置(且必须在每个 worker 节点上维护)。

  • region_name – AWS region_name。如果未指定,则使用默认的 boto3 行为。

  • verify – 是否验证 SSL 证书。请参阅: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客户端的配置字典(键值对)。请参阅: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
ui_color = '#44b5e2'[source]
template_fields: collections.abc.Sequence[str][source]
template_ext: collections.abc.Sequence[str] = ('.sql',)[source]
template_fields_renderers[source]
query[source]
database[source]
output_location = None[source]
client_request_token = None[source]
workgroup = 'primary'[source]
query_execution_context[source]
result_configuration[source]
sleep_time = 30[source]
max_polling_attempts = 999999[source]
query_execution_id: str | None = None[source]
log_query: bool = True[source]
deferrable = True[source]
catalog: str = 'AwsDataCatalog'[source]
execute(context)[source]

在 Amazon Athena 上运行 Trino/Presto 查询。

execute_complete(context, event=None)[source]
on_kill()[source]

取消已提交的 Amazon Athena 查询。

get_openlineage_facets_on_complete(_)[source]

通过解析 SQL 查询并使用 Athena API 丰富数据来检索 OpenLineage 数据。

除了 CTAS 查询,查询和计算结果还存储在 S3 位置。因此,此位置会附加额外的输出。我们不使用保存结果的完整路径(用户前缀 + 某个 UUID),而是仅使用用户提供的路径创建数据集。这应该有助于在不同进程中更容易地匹配此数据集。

get_openlineage_dataset(database, table)[source]

此条目有帮助吗?