airflow.providers.databricks.hooks.databricks_sql

屬性

LIST_SQL_ENDPOINTS_ENDPOINT

T

DatabricksSqlHook

用於與 Databricks SQL 互動的 Hook。

函式

create_timeout_thread(cur, execution_timeout)

模組內容

airflow.providers.databricks.hooks.databricks_sql.LIST_SQL_ENDPOINTS_ENDPOINT = ('GET', 'api/2.0/sql/endpoints')[source]
airflow.providers.databricks.hooks.databricks_sql.T[source]
airflow.providers.databricks.hooks.databricks_sql.create_timeout_thread(cur, execution_timeout)[source]
class airflow.providers.databricks.hooks.databricks_sql.DatabricksSqlHook(databricks_conn_id=BaseDatabricksHook.default_conn_name, http_path=None, sql_endpoint_name=None, session_configuration=None, http_headers=None, catalog=None, schema=None, caller='DatabricksSqlHook', **kwargs)[source]

基礎類: airflow.providers.databricks.hooks.databricks_base.BaseDatabricksHook, airflow.providers.common.sql.hooks.sql.DbApiHook

用於與 Databricks SQL 互動的 Hook。

引數:
  • databricks_conn_id (str) – 引用 Databricks 連線

  • http_path (str | None) – 可選字串,指定 Databricks SQL Endpoint 或叢集的 HTTP 路徑。如果未指定,應在 Databricks 連線的額外引數中指定,或者必須指定 sql_endpoint_name

  • sql_endpoint_name (str | None) – Databricks SQL Endpoint 的可選名稱。如果未指定,則必須提供 http_path,如上所述。

  • session_configuration (dict[str, str] | None) – Spark 會話引數的可選字典。預設為 None。如果未指定,可在 Databricks 連線的額外引數中指定。

  • http_headers (list[tuple[str, str]] | None) – 可選的 (k, v) 對列表,將作為 HTTP 頭新增到每個請求中

  • catalog (str | None) – 要使用的可選初始目錄。需要 DBR 版本 9.0+

  • schema (str | None) – 要使用的可選初始 schema。需要 DBR 版本 9.0+

  • kwargs – Databricks SQL 聯結器引數內部的其他引數

hook_name = 'Databricks SQL'[source]
supports_autocommit = True[source]
session_config = None[source]
http_headers = None[source]
catalog = None[source]
schema = None[source]
additional_params[source]
get_conn()[source]

返回一個 Databricks SQL 連線物件。

run(sql: str | collections.abc.Iterable[str], autocommit: bool = ..., parameters: collections.abc.Iterable | collections.abc.Mapping[str, Any] | None = ..., handler: None = ..., split_statements: bool = ..., return_last: bool = ..., execution_timeout: datetime.timedelta | None = None) None[source]
run(sql: str | collections.abc.Iterable[str], autocommit: bool = ..., parameters: collections.abc.Iterable | collections.abc.Mapping[str, Any] | None = ..., handler: Callable[[Any], T] = ..., split_statements: bool = ..., return_last: bool = ..., execution_timeout: datetime.timedelta | None = None) tuple | list[tuple] | list[list[tuple] | tuple] | None

執行命令或命令列表。

將 SQL 語句列表傳遞給 SQL 引數,使其按順序執行。

引數:
  • sql – 要執行的 sql 語句 (str) 或要執行的 sql 語句列表

  • autocommit – 在執行查詢前要將連線的 autocommit 設定為何值。請注意,目前 Databricks SQL 中沒有 commit 功能,因此此標誌無效。

  • parameters – 用於渲染 SQL 查詢的引數。

  • handler – 結果處理器,將使用每個語句的結果呼叫它。

  • split_statements – 是否將單個 SQL 字串拆分成語句並單獨執行

  • return_last – 拆分後是僅返回最後一條語句的結果,還是返回所有語句的結果

  • execution_timeout – 此任務例項允許執行的最長時間,如果超過此時間將引發錯誤並失敗。

返回值:

如果提供了 handler 且 return_last 未設定為 False,則僅返回最後一條 SQL 表示式的結果。

abstract bulk_dump(table, tmp_file)[source]

將資料庫錶轉儲為製表符分隔檔案。

引數:
  • table – 源表的名稱

  • tmp_file – 目標檔案的路徑

abstract bulk_load(table, tmp_file)[source]

將製表符分隔檔案載入到資料庫表中。

引數:
  • table – 目標表的名稱

  • tmp_file – 要載入到表中的檔案的路徑

此條目是否有幫助?