airflow.providers.apache.hive.transfers.hive_to_mysql

此模組包含一個用於將資料從 Hive 移動到 MySQL 的運算子。

HiveToMySqlOperator

將資料從 Hive 移動到 MySQL。

模組內容

class airflow.providers.apache.hive.transfers.hive_to_mysql.HiveToMySqlOperator(*, sql, mysql_table, hiveserver2_conn_id='hiveserver2_default', mysql_conn_id='mysql_default', mysql_preoperator=None, mysql_postoperator=None, bulk_load=False, hive_conf=None, **kwargs)[source]

Bases: airflow.models.BaseOperator

將資料從 Hive 移動到 MySQL。

請注意,目前資料在推送到 MySQL 之前會載入到記憶體中,因此此運算子應僅用於少量資料。

引數:
  • sql (str) – 要針對 Hive 伺服器執行的 SQL 查詢。(模板化)

  • mysql_table (str) – 目標 MySQL 表,使用點表示法指定特定資料庫。(模板化)

  • mysql_conn_id (str) – 源 MySQL 連線

  • hiveserver2_conn_id (str) – 對 Hive Server2 Thrift 服務連線 ID 的引用。

  • mysql_preoperator (str | None) – 在匯入之前針對 MySQL 執行的 SQL 語句,通常用於截斷或刪除將要匯入的資料,使任務具有冪等性(執行兩次任務不會重複載入資料)。(模板化)

  • mysql_postoperator (str | None) – 匯入後針對 MySQL 執行的 SQL 語句,通常用於將資料從暫存區移動到生產環境並執行清理命令。(模板化)

  • bulk_load (bool) – 使用 bulk_load 選項的標誌。這會使用 LOAD DATA LOCAL INFILE 命令直接從製表符分隔的文字檔案載入資料到 MySQL。MySQL 伺服器必須支援透過此命令載入本地檔案(預設情況下停用)。

  • hive_conf (dict | None)

template_fields: collections.abc.Sequence[str] = ('sql', 'mysql_table', 'mysql_preoperator', 'mysql_postoperator')[source]
template_ext: collections.abc.Sequence[str] = ('.sql',)[source]
template_fields_renderers[source]
ui_color = '#a0e08c'[source]
sql[source]
mysql_table[source]
mysql_conn_id = 'mysql_default'[source]
mysql_preoperator = None[source]
mysql_postoperator = None[source]
hiveserver2_conn_id = 'hiveserver2_default'[source]
bulk_load = False[source]
hive_conf = None[source]
execute(context)[source]

在建立運算子時派生。

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

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

此條目是否有幫助?