airflow.providers.microsoft.azure.hooks.duckdb¶
Attributes¶
Classes¶
Interact with DuckDB using Azure credentials brokered by Airflow. |
Module Contents¶
- class airflow.providers.microsoft.azure.hooks.duckdb.AzureDuckDBHook(*args, azure_conn_id=None, account_name=None, credential_strategy=None, credential_chain=None, transport_option_type=None, secret_name=None, **kwargs)[source]¶
Bases:
airflow.providers.duckdb.hooks.duckdb.DuckDBHookInteract with DuckDB using Azure credentials brokered by Airflow.
Extends
DuckDBHookwith an Azure secret built from an Airflow ADLS connection, soread_parquet('abfss://...'),delta_scan('abfss://...')andCOPY ... TO 'abfss://...'work with no credential wiring in the Dag. It is the Azure counterpart ofAwsDuckDBHook.Two credential strategies are supported:
config(the default)Builds the secret from the credentials of the ADLS connection, read in the order
AzureDataLakeStorageV2Hookreads them: itsconnection_stringwhen the extra has one (PROVIDER config), else an Active Directory service principal when the extra has atenant_id(PROVIDER service_principal, with the connection’s login as client id and its password as client secret), else the password as the key of the storage account (PROVIDER config, with a connection string built from the account and the key). A connection without credentials is rejected: usecredential_chainfor it. The extra’sproxies["https"]becomes the secret’s proxy. The credentials become part of the SQL statement.credential_chainIssues
CREATE SECRET (TYPE azure, PROVIDER credential_chain), which resolves credentials through the Azure SDK inside DuckDB’sazureextension (Azure CLI, managed identity, workload identity, environment). Nothing secret is written into SQL text. The default ADLS connection is optional then: when it exists, it supplies the storage account and proxy. Anazure_conn_idother than the default has to exist. The chain does not read the connection’smanaged_identity_client_idorworkload_identity_tenant_id.
The storage account comes from
account_name, else from theaccount_urlof the ADLS connection’s extra (onelakeforhttps://onelake.dfs.fabric.microsoft.com), else from its host.This hook needs the
azureextension and installs it if it is missing, asAwsDuckDBHookdoes withhttpfsandaws. Setautoinstall_extensions=Falseto forbid the download.- Parameters:
azure_conn_id (str | None) – the ADLS connection used to reach the storage. Defaults to
adls_default.account_name (str | None) – the storage account of the secret. Defaults to the ADLS connection’s.
credential_strategy (CredentialStrategy | None) –
config,credential_chain, ornoneto create no secret at all (for a DuckDB database that never touches Azure).credential_chain (str | None) – providers DuckDB’s credential chain consults, for example
"managed_identity;env". Only used with thecredential_chainstrategy; DuckDB’s own default applies when it is not set.transport_option_type (Literal['default', 'curl'] | None) – the HTTP transport of the Azure SDK in DuckDB (the
azure_transport_option_typesetting):defaultorcurl.curlsearches the usual locations for the CA bundle, which resolves TLS certificate errors on Linux systems whose bundle is not where the default transport looks. Left unset, DuckDB’s default applies.secret_name (str | None) – name of the DuckDB secret to create.
As with
DuckDBHook, every parameter may also be set in the DuckDB connectionextra, and an explicit argument wins.- classmethod get_ui_field_behaviour()[source]¶
Return custom UI field behaviour for the DuckDB on Azure connection.
- property azure_connection: airflow.providers.common.compat.sdk.Connection[source]¶
Return the ADLS connection the secret is built from.
- property optional_azure_connection: airflow.providers.common.compat.sdk.Connection | None[source]¶
Return the ADLS connection, or
Nonewhen the default one does not exist.With the
credential_chainstrategy the ADLS connection only supplies the storage account and proxy, so the default one may be missing. A connection named explicitly has to exist, as for the DuckDB connection itself: leaving it out would create a secret without the account and proxy the Dag author asked for.
- property credential_strategy: CredentialStrategy[source]¶
- property autoinstall_extensions: bool[source]¶
Default to installing missing extensions, unlike the generic hook.
Reaching for the Azure hook is a statement that the task runs against Azure, so
azureshould just work. The generic hook cannot assume that and leaves downloads off.