airflow.providers.apache.hive.transfers.mssql_to_hive

此模組包含一個用於將資料從 MSSQL 移動到 Hive 的 operator。

MsSqlToHiveOperator

將資料從 Microsoft SQL Server 移動到 Hive。

模組內容

class airflow.providers.apache.hive.transfers.mssql_to_hive.MsSqlToHiveOperator(*, sql, hive_table, create=True, recreate=False, partition=None, delimiter=chr(1), mssql_conn_id='mssql_default', hive_cli_conn_id='hive_cli_default', hive_auth=None, tblproperties=None, **kwargs)[source]

基類: airflow.models.BaseOperator

將資料從 Microsoft SQL Server 移動到 Hive。

該 operator 對 Microsoft SQL Server 執行你的查詢,在將檔案載入到 Hive 表之前將其儲存在本地。如果 createrecreate 引數設定為 True,將生成 CREATE TABLEDROP TABLE 語句。

Hive 資料型別根據遊標的元資料推斷得出。請注意,在 Hive 中生成的表使用 STORED AS textfile,這不是最高效的序列化格式。如果載入了大量資料和/或表被頻繁查詢,你可能只希望使用此 operator 將資料暫存到臨時表中,然後再使用 HiveOperator 將其載入到最終目的地。

引數:
  • sql (str) – 對 Microsoft SQL Server 資料庫執行的 SQL 查詢。(可模板化)

  • hive_table (str) – 目標 Hive 表,使用點記法指定特定資料庫。(可模板化)

  • create (bool) – 如果表不存在是否建立

  • recreate (bool) – 每次執行時是否刪除並重新建立表

  • partition (dict | None) – 目標分割槽,以字典形式表示分割槽列和值。(可模板化)

  • delimiter (str) – 檔案中的欄位分隔符

  • mssql_conn_id (str) – 源 Microsoft SQL Server 連線

  • hive_cli_conn_id (str) – 參考 Hive CLI 連線 ID

  • hive_auth (str | None) – 為 Hive 連線傳遞的可選認證選項

  • tblproperties (dict | None) – 正在建立的 hive 表的 TBLPROPERTIES

template_fields: collections.abc.Sequence[str] = ('sql', 'partition', 'hive_table')[source]
template_ext: collections.abc.Sequence[str] = ('.sql',)[source]
template_fields_renderers[source]
ui_color = '#a0e08c'[source]
sql[source]
hive_table[source]
partition = None[source]
create = True[source]
recreate = False[source]
delimiter[source]
mssql_conn_id = 'mssql_default'[source]
hive_cli_conn_id = 'hive_cli_default'[source]
tblproperties = None[source]
hive_auth = None[source]
classmethod type_map(mssql_type)[source]

將 MsSQL 型別對映到 Hive 型別。

execute(context)[source]

建立 operator 時推導。

Context 是用於渲染 Jinja 模板時使用的相同字典。

有關更多 context,請參閱 get_template_context。

此條目有幫助嗎?