3 ms·
It's never quite been clear to me what the advantage of dbt over a python program using sqlalchemy / duckdb / polars to transform data is. Can you enlighten me?
by sanderjd 1mo ago
It's never quite been clear to me what the advantage of dbt over a python program using sqlalchemy / duckdb / polars to transform data is. Can you enlighten me?
- vovavili 1mo agoAt the minimum, it's just Jinja2 templates in your SQL queries - meaning, you can do pure SQL transformations with conditional logic in your templates. In addition to being able to run tests, specify custom macros, having version control and having some constrained way to organize your tables, you're turning SQL into a proper programming language with just one library.
- throwaway7783 1mo agoMy issue with DBT is it is a mix of SQL, yaml, jinja2 flow controls (and metrics is whole another thing). SQL with jinja2 if/else can get really unmaintainable quickly. It's perhaps better than homegrown sql based transformers. polars is code and can be version controlled too. Dataframes in my opinion are more elegant, and with the right backends and some lineage enhancements, could serve a much wider set of use cases than what DBT does
- vovavili 1mo agoDifferent tools for different tasks.
- sanderjd 1mo agoBut is that ... good?
- vovavili 1mo agoIt's definitely better than raw 500+ lines of SQL composed with 300+ lines of Python for some bespoke business transformation without clean versioning, which is what SQL transformations tend to converge towards without something like dbt.
- geysersam 1mo agoVersioning seems like a separate problem, no? I mean, you can version control your python program generating SQL queries
- sanderjd 1mo agoYeah that's fair. In practice, the projects I've worked on have always seemed to end up with a mix of all of dbt, SQL strings in python, and dataframe manipulation. I've always felt like we should be able to minimize one of these in favor of the others, but in practice it seems like people find each of these things useful for different things.