Skip to content

targets

etl_craft.config.targets

What a warehouse connection points at: its JDBC URL's parts, its dialect and its catalog.

Most warehouses use the jdbc:<scheme>://host[:port]/database[?query] form. DuckDB names a file, Databricks puts semicolon parameters after the path, and Snowflake keeps the database in the query string, so each of those has its own parser here.

WarehouseUrl dataclass

The parts of a warehouse JDBC URL.

dialect is the SQLAlchemy dialect name, with its driver where one is implied. database is what the SQLAlchemy URL's database becomes: catalog/schema for Trino and Snowflake. catalog is the first part of every catalog.schema.table name. path is a DuckDB file, or :memory:.

parse_warehouse_url

parse_warehouse_url(jdbc_url: str) -> WarehouseUrl

Split a warehouse JDBC URL into its parts; ConfigurationError if it is malformed.

strip_databricks_credentials

strip_databricks_credentials(jdbc_url: str) -> str

Drop credential and driver parameters from a Databricks JDBC URL.

The URL Databricks' "Connection Details" page offers includes AuthMech, UID and a real token in PWD; what is left is safe to keep.

preferred_connection_url

preferred_connection_url(name: str, fields: Mapping[str, str]) -> str

Build a credential-free JDBC URL from Databricks' or Snowflake's separate fields.

name is Warehouse.Name. Every preferred field except the token must be present.

active_warehouse

active_warehouse(config: ConnectorConfig) -> WarehouseSpec

Return the dialect the active warehouse profile and the default table format select.

active_catalog

active_catalog(config: ConnectorConfig) -> str

Return the catalog the active warehouse profile writes into.

It is the first part of every catalog.schema.table name the engine builds; the schema and table come from CFG_ rows. DuckDB over Iceberg names it in the profile's catalog; every other warehouse names it in its URL.

attached_catalog_name

attached_catalog_name(profile_extra: Mapping[str, object]) -> str

Return the name DuckDB attaches an Iceberg catalog as: the profile's catalog.

It is written unquoted into catalog.schema.table, so it must be a plain identifier.