warehouse
- base
- databricks
- databricks_iceberg
- duckdb
- duckdb_iceberg
- postgres
- registry
- replacement
- snowflake
- snowflake_iceberg
- trino_iceberg
etl_craft.dialects.warehouse ¶
Warehouse dialects: one per database and table format.
postgres native tables
duckdb native tables in a local file
duckdb_iceberg DuckDB compute over an Iceberg REST catalog
trino_iceberg Trino over an Iceberg catalog
databricks Delta tables
databricks_iceberg Delta tables with UniForm, readable as Iceberg
snowflake ordinary Snowflake tables
snowflake_iceberg Snowflake Iceberg tables
A task's dialect comes from the warehouse connection and the task's table format: its own
TABLE_FORMAT parameter, else Warehouse.Table_format. The vendors' SQLAlchemy dialects are
optional extras; nothing here imports them.
AUDIT_COLUMN_TYPES
module-attribute
¶
AUDIT_COLUMN_TYPES: dict[str, str] = {'TASK_RUN_ID': 'BIGINT', 'PIPELINE_ID': 'BIGINT', 'HASH_KEY': 'VARCHAR(32)', 'CREATE_DATE': 'TIMESTAMP WITH TIME ZONE', 'UPDATE_DATE': 'TIMESTAMP WITH TIME ZONE', 'CREATED_BY': 'VARCHAR(255)', 'UPDATED_BY': 'VARCHAR(255)', 'DELETE_FLAG': 'VARCHAR(1)', 'ACTIVE_FLAG': 'VARCHAR(1)'}
The DDL type of each engine-managed audit column, used to create a column with no rows.
Presented
dataclass
¶
How one new connection presents its credential to the driver.
username and password go into the SQLAlchemy URL built inside the connection
creator, never the engine's own logged URL. query joins that URL's query string, for
drivers that read auth settings there (Trino). connect_args are passed to the driver
after the dialect's own connect arguments, for settings that must never travel in a URL.
WarehouseDialect ¶
What differs between warehouses; the defaults are the ANSI behaviour PostgreSQL follows.
replace_strategy
class-attribute
instance-attribute
¶
How a replacement protects an existing target from a failed write.
identity_in_create
class-attribute
instance-attribute
¶
Whether ROW_ID must be declared when creating the table, rather than added later.
session_sql
class-attribute
instance-attribute
¶
Setup SQL for each new warehouse connection.
overwrite_uses_ctas
class-attribute
instance-attribute
¶
Whether an overwrite publishes a replacement snapshot with CTAS.
update_uses_merge
class-attribute
instance-attribute
¶
Whether a joined update needs MERGE rather than UPDATE ... FROM.
identity_table_ddl ¶
Create an empty table with the supplied columns and a generated ROW_ID.
identity_replacement_ddl ¶
identity_replacement_ddl(conn: Connection, target: str, candidate: str, columns: str, params: Mapping[str, str], *, existing: bool) -> tuple[str, str]
Return candidate creation and atomic publication SQL for an identity table.
existing_table_format ¶
Read a table's format, or use the sole format supported by this dialect.
row_id_generated ¶
Whether inserts into this existing table omit ROW_ID and let its default fill it.
present ¶
Return how one new connection authenticates by profile.auth_mode.
Called once per connection, so a credential minted here is current. The defaults: a
user and password, a bearer token in the password position, and a private key through
key_file_connect_args.
present_bearer ¶
Present a bearer token in the password position.
oauth_token ¶
Mint an access token by the profile's client-credentials grant.
on_connect ¶
Apply this dialect's session settings, closing its setup cursor on failure too.
load_table_metadata ¶
Make information_schema.columns describe schema.table; it already does by default.
create_table_clause ¶
Return the clause between CREATE TABLE <name> and AS <select>.
create_table_as ¶
create_table_as(conn: Connection, qualified_name: str, select_sql: str, params: Mapping[str, str]) -> None
Run CREATE TABLE ... AS SELECT in this dialect's table format.
params are the task's parameters, for dialects that read storage settings there.
replacement_comment ¶
Capture the comment before a transactional replacement removes the old object.
preserve_replacement_properties ¶
Refuse promotion unless the dialect can preserve the target's protected properties.
backup_table ¶
Keep a durable row copy without reusing the target's configured storage path.
replacement_ddl ¶
replacement_ddl(conn: Connection, target: str, select_sql: str, params: Mapping[str, str], *, existing: bool) -> str
Render a single atomic replacement, or refuse when the dialect cannot do it.
overwrite_statement ¶
Replace rows without a separate truncate, where the warehouse supports it.
mirror_table_ddl ¶
Return the DDL for a cloning mirror, or None for a plain CREATE TABLE.
task_storage_problem ¶
Return why a task's storage parameters cannot work here, or None.
unsupported_storage_problem ¶
Return which storage parameters the task sets that do not apply here, or None.
Such a parameter would be ignored, leaving the table somewhere the author did not intend.
cloning_storage_problem ¶
Return why cloning cannot create mirrors here as configured, or None.
alter_table_keyword ¶
Return the keyword that alters a table this dialect created.
column_metadata_query ¶
column_metadata_query(conn: Connection, table: str, columns: str) -> tuple[str, dict[str, str | None]]
Read information-schema columns for a bare, schema- or catalog-qualified table.
full_column_types ¶
Read reusable DDL types, including nested types and declared sizes.
full_column_type ¶
Return a column's complete warehouse type, refusing missing metadata.
column_addition_problem ¶
Return why this type cannot be added without rebuilding, or None.
same_column_type ¶
Compare types as this warehouse stores and reports them.
evolution_column_type ¶
Return the full stage type in the target table format's DDL representation.
is_bigint_type ¶
Whether a stored column has the signed BIGINT type used for task-run ids.
audit_column_type ¶
Return the DDL type of an engine-managed audit column.
scratch_table_keyword ¶
Return TEMPORARY TABLE, or TABLE where temporary tables are unusable.
hash_expression ¶
Return the version-2 MD5 of typed, NULL-tagged, length-prefixed values.
canonical_text ¶
Render supported scalar values independently of session output formats.
decimal_text ¶
Keep the decimal's declared scale, including trailing zeroes.
timestamp_text ¶
Render a UTC timestamp with exactly six fractional digits.
update_from_stage ¶
update_from_stage(target: str, stage: str, keys: tuple[str, ...], assignments: Mapping[str, str], condition: str) -> str
Update matching target rows from a deduplicated stage using aliases t and s.
prepare_update_stage ¶
Statements that prepare a stage for joined updates on its merge keys.
all_dialects
cached
¶
Return one instance of every warehouse dialect.
for_key ¶
Return the dialect registered under key, such as trino_iceberg.
resolve ¶
Choose the dialect for a connection's SQLAlchemy name and a table format.
Trino is Iceberg whichever format is asked for, because its catalog decides; PostgreSQL has
no Iceberg tables; an unsupported database is a ConfigurationError.