airflow.providers.amazon.aws.transfers.redshift_to_s3

將資料從 AWS Redshift 傳輸到 S3 桶中。

RedshiftToS3Operator

執行 UNLOAD 命令到 S3,生成包含標頭的 CSV 檔案。

模組內容

class airflow.providers.amazon.aws.transfers.redshift_to_s3.RedshiftToS3Operator(*, s3_bucket, s3_key, schema=None, table=None, select_query=None, redshift_conn_id='redshift_default', aws_conn_id=NOTSET, verify=None, unload_options=None, autocommit=False, include_header=False, parameters=None, table_as_file_name=True, redshift_data_api_kwargs=None, **kwargs)[原始碼]

基類: airflow.models.BaseOperator

執行 UNLOAD 命令到 S3,生成包含標頭的 CSV 檔案。

另請參閱

有關如何使用此運算子的更多資訊,請參閱指南: Amazon Redshift 到 Amazon S3 傳輸運算子

引數:
  • s3_bucket (str) – 對特定 S3 桶的引用

  • s3_key (str) – 對特定 S3 鍵的引用。如果 table_as_file_name 設定為 False,則此引數必須包含所需的檔名

  • schema (str | None) – 對 Redshift 資料庫中特定 schema 的引用,在提供了 table 引數且未提供 select_query 引數時使用。解除安裝臨時表時請勿提供此引數

  • table (str | None) – 對 Redshift 資料庫中特定表的引用,在提供了 schema 引數且未提供 select_query 引數時使用

  • select_query (str | None) – 用於從 Redshift 資料庫獲取資料的自定義 select 查詢,優先於預設查詢 SELECT * FROM ``schema`.``table``

  • redshift_conn_id (str) – 對特定 Redshift 資料庫的引用

  • aws_conn_id (str | None | airflow.utils.types.ArgNotSet) – 對特定 S3 連線的引用。如果 AWS 連線在 extras 中包含“aws_iam_role”,運算子將使用帶有 token 的 AWS STS 憑證 https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-authorization.html#copy-credentials

  • verify (bool | str | None) –

    是否驗證 S3 連線的 SSL 證書。預設情況下,SSL 證書會被驗證。您可以提供以下值:

    • False: 不驗證 SSL 證書。SSL 仍然會使用

      (除非 use_ssl 設定為 False),但 SSL 證書不會被驗證。

    • path/to/cert/bundle.pem: 要使用的 CA 證書捆綁檔案的檔名。

      如果您想使用與 botocore 使用的不同的 CA 證書捆綁包,可以指定此引數。

  • unload_options (list | None) – 對 UNLOAD 選項列表的引用

  • autocommit (bool) – 如果設定為 True,將自動提交 UNLOAD 語句。否則,它將在 Redshift 連線關閉前提交。

  • include_header (bool) – 如果設定為 True,則 S3 檔案包含標題列。

  • parameters (collections.abc.Iterable | collections.abc.Mapping | None) – (可選)用於渲染 SQL 查詢的引數。

  • table_as_file_name (bool) – 如果設定為 True,則 S3 檔案將以表名命名。在提供了 table 引數時適用。

  • redshift_data_api_kwargs (dict | None) – 如果使用 Redshift Data API 而不是基於 SQL 的連線,則為 hook 的 execute_query 方法的引數字典。不能包含以下任何 kwargs: {'sql', 'parameters'}

template_fields: collections.abc.Sequence[str] = ('s3_bucket', 's3_key', 'schema', 'table', 'unload_options', 'select_query', 'redshift_conn_id',...[原始碼]
template_ext: collections.abc.Sequence[str] = ('.sql',)[原始碼]
template_fields_renderers[原始碼]
ui_color = '#ededed'[原始碼]
s3_bucket[原始碼]
s3_key[原始碼]
schema = None[原始碼]
table = None[原始碼]
redshift_conn_id = 'redshift_default'[原始碼]
verify = None[原始碼]
unload_options = [][原始碼]
autocommit = False[原始碼]
include_header = False[原始碼]
parameters = None[原始碼]
table_as_file_name = True[原始碼]
redshift_data_api_kwargs[原始碼]
select_query = None[原始碼]
property default_select_query: str | None[原始碼]
property use_redshift_data[原始碼]
execute(context)[原始碼]

建立運算子時派生。

上下文與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

get_openlineage_facets_on_complete(task_instance)[原始碼]

實現 on_complete,因為我們可能會查詢表詳情。

此條目有幫助嗎?