Outputs & Schemas¶
DBPort uses explicit output contracts. Every dataset must declare its schema before data is written.
Declaring a schema¶
The table is created in DuckDB and the schema (DDL + column list) is persisted to dbport.lock.
Schema drift protection¶
If the output table already exists in the warehouse, DBPort compares the local DDL against the warehouse schema. Incompatible changes raise SchemaDriftError:
SchemaDriftError: Schema drift detected:
+ new_column (string) # (1)!
- old_column (int32) # (2)!
~ value (int32 → float64) # (3)!
- Column added locally but not present in the warehouse.
- Column exists in the warehouse but was removed from the local DDL.
- Column type changed between local and warehouse schema.
This check runs at schema declaration time (early fail-fast) and again at publish time (safety net).
Idempotent schema declaration
Declaring the same schema repeatedly is safe — the table is created or replaced in DuckDB without error. Only incompatible changes relative to the warehouse trigger SchemaDriftError.
Column metadata¶
After declaring a schema, every column gets a default codelist entry. Override metadata per column:
See Metadata & Codelists for full details.