Use Python models in dbt-duckdb
masterdbt-duckdb executes Python models in the same process that owns the DuckDB connection (the Python process running dbt).
Key details:
- Execution: The
.pyfile is treated as a module and loaded viaimportlib. - Arguments: The
modelfunction receives adbtobject (forrefandsourcecalls) and aDuckDBPyConnectionobject. - Data Types:
dbt.refanddbt.sourcereturn DuckDB Relation objects. These can be converted to Pandas/Polars DataFrames or Arrow tables. - Return Values: The
modelfunction can return any object DuckDB can materialize into a table, such as a Pandas/PolarsDataFrame, a DuckDBRelation, an ArrowTable,Dataset,RecordBatchReader, orScanner.