12 Sep Using macros in dbtvault – Links
Links in dbtvault
Welcome back to our series of videos introducing dbtvault, in which we are showing you dbtvault tips and tricks, aimed particularly at beginners. This is the third video in the series “Using macros provided in dbtvault”. Alex, the lead developer of dbtvault, will show you how to create a link in dbtvault and show you the lineage of all data flowing to the created link.
This is a continuation from the second video and Alex assumes that you have a stage view created using the dbtvault stage macro as well as the hub that he showed us in the second video – as the steps to create a link are very similar. If you missed that video, we suggest you go back and watch the first two videos, as this will make it easier to follow and understand.
First video – Staging
Second video – Hubs
In this video we are creating a link called “CUSTOMER_ORDER”. We start off by creating a links folder, within the raw vault folder. This is a good practice to keep things tidy and organised. Once this has been created, Alex copies his SQL code from the Hub which he created earlier as it has a lot of similarities and proceeds to edit the code – which is faster than typing it all out again. One key change is changing the “nk” (natural key) to “fk” (foreign keys) which are the primary keys of the hub that we are relating in the link. Note that this is now a list as there are multiple foreign keys.
Now that the metadata has been provided, we need to change the macro call for the dbtvault macro from the hub macro to the link macro. You can find the code he is using in the dbtvault documentation or just type it out as shown in the video. You can find the dbtvault documentation here.
Near the end of the video – Alex opens snowflake to demonstrate the created link and generated documentation to show you the lineage of all the data flowing to the link “CUSTOMER_ORDER”
Look out for the next video which will be about Satellites. Lastly, we offer support for dbtvault – which you can find out more about by clicking here.