airflow.providers.microsoft.azure.hooks.duckdb

Attributes

CredentialStrategy

DEFAULT_AZURE_CONN_ID

Classes

AzureDuckDBHook

Interact with DuckDB using Azure credentials brokered by Airflow.

Module Contents

airflow.providers.microsoft.azure.hooks.duckdb.CredentialStrategy[source]
airflow.providers.microsoft.azure.hooks.duckdb.DEFAULT_AZURE_CONN_ID = 'adls_default'[source]
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.DuckDBHook

Interact with DuckDB using Azure credentials brokered by Airflow.

Extends DuckDBHook with an Azure secret built from an Airflow ADLS connection, so read_parquet('abfss://...'), delta_scan('abfss://...') and COPY ... TO 'abfss://...' work with no credential wiring in the Dag. It is the Azure counterpart of AwsDuckDBHook.

Two credential strategies are supported:

config (the default)

Builds the secret from the credentials of the ADLS connection, read in the order AzureDataLakeStorageV2Hook reads them: its connection_string when the extra has one (PROVIDER config), else an Active Directory service principal when the extra has a tenant_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: use credential_chain for it. The extra’s proxies["https"] becomes the secret’s proxy. The credentials become part of the SQL statement.

credential_chain

Issues CREATE SECRET (TYPE azure, PROVIDER credential_chain), which resolves credentials through the Azure SDK inside DuckDB’s azure extension (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. An azure_conn_id other than the default has to exist. The chain does not read the connection’s managed_identity_client_id or workload_identity_tenant_id.

The storage account comes from account_name, else from the account_url of the ADLS connection’s extra (onelake for https://onelake.dfs.fabric.microsoft.com), else from its host.

This hook needs the azure extension and installs it if it is missing, as AwsDuckDBHook does with httpfs and aws. Set autoinstall_extensions=False to 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, or none to 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 the credential_chain strategy; 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_type setting): default or curl. curl searches 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 connection extra, and an explicit argument wins.

required_extensions = ('azure',)[source]
conn_type = 'duckdb_azure'[source]
hook_name = 'DuckDB on Azure'[source]
default_conn_name = 'duckdb_azure_default'[source]
classmethod get_ui_field_behaviour()[source]

Return custom UI field behaviour for the DuckDB on Azure connection.

property azure_conn_id: str[source]
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 None when the default one does not exist.

With the credential_chain strategy 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 credential_chain: str | None[source]
property transport_option_type: str | None[source]
property secret_name: str[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 azure should just work. The generic hook cannot assume that and leaves downloads off.

get_account_name()[source]

Return the storage account of the secret.

configure_secrets(conn)[source]

Set the Azure transport, if one is configured, and create the DuckDB Azure secret.

get_openlineage_database_info(connection)[source]

Return no lineage metadata; a DuckDB database is task-local and has no stable namespace.

Was this entry helpful?