Package: dbt-yellowbrick
dbt-yellowbrickThe dbt-yellowbrick adapter allowsdbtto work withYellowbrick Data Warehouseand leverage the
powerful capabilities of both platforms to build data analysis workflows. This adapter is based on thepostgres-adapterwith
extensions to support Yellowbrick specific features.The dbt-yellowbrick adapter has been developed for projects that implementdbt-corethrough the command-line interface (CLI) which is
available as anopen source project.InstallationThis project is hosted on PyPI, so you should be able to installdbt-yellowbrickand the necessary dependencies via:pip install dbt-yellowbrickThe latest supported version targets dbt-core 1.7.x .dbt Profile ConfigurationHere is a basic example of a profile configuration (profiles.yml) to use withdbt-yellowbrick.yb_test_models:target:devoutputs:dev:type:yellowbrickhost:<host>user:<user_name>password:<password>port:5432dbname:<database_name>schema:<schema_name>threads:1connect_timeout:30# secondsprod:type:yellowbrickhost:<host>user:<user_name>password:<password>port:5432dbname:<database_name>schema:<schema_name>threads:1connect_timeout:30# secondsFeaturesdbt-yellowbrick supports the following Yellowbrick specific features:distributionclusteringsortmaterialisations based on cross-database queriesincremental strategies "append" and "delete+insert"Refer to the officialYellowbrick documentationfor detailed explanation of all of these.Some example model configurationsDISTRIBUTE REPLICATEwith aSORTcolumn...{{config(materialized="table",dist="replicate",sort_col="stadium_capacity")}}selecthash(stg.name)asteam_key,stg.nameasteam_name,stg.nicknameasteam_nickname,stg.cityashome_city,stg.stadiumasstadium_name,stg.capacityasstadium_capacity,stg.avg_attasaverage_game_attendance,current_timestampasmd_create_timestampfrom{{source('premdb_public','team')}}stgwherestg.nameisnotnullgives the following model output:createtableifnotexistsmarts.dim_teamas(selecthash(stg.name)asteam_key,stg.nameasteam_name,stg.nicknameasteam_nickname,stg.cityashome_city,stg.stadiumasstadium_name,stg.capacityasstadium_capacity,stg.avg_attasaverage_game_attendance,current_timestampasmd_create_timestampfrompremdb.public.teamstgwherestg.nameisnotnull)distributeREPLICATEsorton(stadium_capacity);DISTRIBUTEon a single column and define up to fourCLUSTERcolumns...{{config(materialized='table',dist='match_key',cluster_cols=['season_key','match_date_key','home_team_key','away_team_key'])}}selecthash(concat_ws('||',lower(trim(s.season_name)),translate(left(m.match_ts,10),'-',''),lower(trim(h."name")),lower(trim(a."name"))))asmatch_key,hash(lower(trim(s.season_name)))asseason_key,cast(translate(left(m.match_ts,10),'-','')asinteger)asmatch_date_key,hash(lower(trim(h."name")))ashome_team_key,hash(lower(trim(a."name")))asaway_team_key,m.htscore,split_part(m.htscore,'-',1)ashome_team_goals_half_time,split_part(m.htscore,'-',2)asaway_team_goals_half_time,m.ftscore,split_part(m.ftscore,'-',1)ashome_team_goals_full_time,split_part(m.ftscore,'-',2)asaway_team_goals_full_timefrom{{source('premdb_public','match')}}minnerjoin{{source('premdb_public','team')}}hon(m.htid=h.htid)innerjoin{{source('premdb_public','team')}}aon(m.atid=a.atid)innerjoin{{source('premdb_public','season')}}son(m.seasonid=s.seasonid)gives the following model output:createtableifnotexistsmarts.fact_matchas(selecthash(concat_ws('||',lower(trim(s.season_name)),translate(left(m.match_ts,10),'-',''),lower(trim(h."name")),lower(trim(a."name"))))asmatch_key,hash(lower(trim(s.season_name)))asseason_key,cast(translate(left(m.match_ts,10),'-','')asinteger)asmatch_date_key,hash(lower(trim(h."name")))ashome_team_key,hash(lower(trim(a."name")))asaway_team_key,m.htscore,split_part(m.htscore,'-',1)ashome_team_goals_half_time,split_part(m.htscore,'-',2)asaway_team_goals_half_time,m.ftscore,split_part(m.ftscore,'-',1)ashome_team_goals_full_time,split_part(m.ftscore,'-',2)asaway_team_goals_full_timefrompremdb.public.matchminnerjoinpremdb.public.teamhon(m.htid=h.htid)innerjoinpremdb.public.teamaon(m.atid=a.atid)innerjoinpremdb.public.seasonson(m.seasonid=s.seasonid))distributeon(match_key)clusteron(season_key,match_date_key,home_team_key,away_team_key);LimitationsThis is an initial implementation of the dbt adapter for Yellowbrick Data Warehouse and may not support some use cases.
We strongly advise validating all records or transformations resulting from the adapter output.