{"id":832,"date":"2026-01-30T12:21:52","date_gmt":"2026-01-30T12:21:52","guid":{"rendered":"https:\/\/datadandies.nl\/?p=832"},"modified":"2026-01-30T12:21:52","modified_gmt":"2026-01-30T12:21:52","slug":"using-packages-in-dbt-to-automate-tedious-tasks-like-writing-your-own-sources-yml","status":"publish","type":"post","link":"https:\/\/datadandies.nl\/index.php\/2026\/01\/30\/using-packages-in-dbt-to-automate-tedious-tasks-like-writing-your-own-sources-yml\/","title":{"rendered":"Using packages in dbt to automate tedious tasks like writing your own sources.yml"},"content":{"rendered":"\n<p>Are you a lazy engineer? Then you are good engineer.<\/p>\n\n\n\n<p>Being lazy\/good at automation of processes helps save work, time and money.<\/p>\n\n\n\n<p>In Data Build Tool (dbt) there are several packages that can help automate tedious tasks.<\/p>\n\n\n\n<p>The dbt-codegen package provides you with the macro\u2019s generate_base_model and generate_source, among others.<\/p>\n\n\n\n<p>Macro\u2019s in dbt are essentially functions that make your life easier.<\/p>\n\n\n\n<p>The generate_base_model macro creates a SQL statement {{ including( \u2018relevant jinja\u2019 ) }} (see what I did there) that includes all the column names.<\/p>\n\n\n\n<p>In staging layers, it is best practise to explicitly write out all the column names that you want to include in the resulting model (meaning, no \u201cselect *&#8230;\u201d but \u201cselect column1, column2, etc&#8230;\u201d). This is because whenever there are schema changes, like extra columns added, they get picked up automatically by \u201cselect *&#8230;\u201d, whether you want it or not. This can result in errors downstream, among other things.<\/p>\n\n\n\n<p>Writing out all column names can become really annoying, real fast though, when you\u2019re dealing with tables with hundreds of columns.<\/p>\n\n\n\n<p>Having to write all those columns yourself or jumping through hoops like Snowflake &gt; add columns in editor &gt; format &gt; copy &gt; etc. = BIG sad.<\/p>\n\n\n\n<p>The generate_base_model macro does this for you. It creates a SQL statement with all the columns.<\/p>\n\n\n\n<p>Then there is the generate_source macro. This macro generates sources.yml, when you have not created it yourself yet. Also very handy and efficient. Moral of the story is, keep being lazy.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you a lazy engineer? Then you are good engineer. Being lazy\/good at automation of processes helps save work, time and money. In Data Build Tool (dbt) there are several packages that can help automate tedious tasks. The dbt-codegen package provides you with the macro\u2019s generate_base_model and generate_source, among others. Macro\u2019s in dbt are essentially&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/datadandies.nl\/index.php\/2026\/01\/30\/using-packages-in-dbt-to-automate-tedious-tasks-like-writing-your-own-sources-yml\/\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[69],"class_list":["post-832","post","type-post","status-publish","format-standard","hentry","category-blog","tag-dbt"],"_links":{"self":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/comments?post=832"}],"version-history":[{"count":1,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/832\/revisions"}],"predecessor-version":[{"id":833,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/832\/revisions\/833"}],"wp:attachment":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/media?parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/categories?post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/tags?post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}