<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gijs de Kruif on Medium]]></title>
        <description><![CDATA[Stories by Gijs de Kruif on Medium]]></description>
        <link>https://medium.com/@gijsdekruif?source=rss-15c848a9973e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wutKNEXwL9f-b_X2</url>
            <title>Stories by Gijs de Kruif on Medium</title>
            <link>https://medium.com/@gijsdekruif?source=rss-15c848a9973e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:14:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gijsdekruif/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[DBT at HomeToGo]]></title>
            <link>https://engineering.hometogo.com/dbt-at-hometogo-ece067987267?source=rss-15c848a9973e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ece067987267</guid>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[modern-data-stack]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Gijs de Kruif]]></dc:creator>
            <pubDate>Wed, 06 Oct 2021 14:52:49 GMT</pubDate>
            <atom:updated>2021-10-13T09:14:05.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*e6BrCbX0w3DU5zkBOgEYNg.png" /></figure><h4>Creating a scalable framework for our data transformation process</h4><h4>This article details HomeToGo’s introduction of dbt (data build tool) as its main tool for all transformations in its ELT (extract, load, transform) process. This article is part of a larger series of readings that detail <a href="https://engineering.hometogo.com/the-evolution-of-our-data-tech-stack-59ce757f5060">the evolution of the Data Tech Stack at HomeToGo</a>.</h4><h3>Introduction</h3><p>HomeToGo is a marketplace with the world’s largest selection of vacation rentals. We list millions of offers from thousands of trusted partners to make incredible accommodation easily accessible to everyone.</p><p>Data is an important factor in almost everything we do. From evaluating the performance of our partners, developing data products, measuring the performance of our marketing campaigns and making data-informed decisions on a strategic level, data has an impact across all departments at HomeToGo.</p><p>One challenge we face when data is transformed and interpreted by different teams across HomeToGo is how to give flexibility to each team to measure what they need, while simultaneously keeping people aligned on measures applicable across teams. To complicate this further, we want to stick to a “single” standard of best practices but the interpretation of “best practice” varies depending on who you ask!</p><h3>dbt</h3><p>Over the last couple of years, <a href="https://www.getdbt.com/">dbt</a> (data build tool) has gained a lot of traction as the tool to do the T (transform) in the ELT process. dbt offers a strong framework for our Data teams to work together, which reduces the risk of isolating definitions into different teams and sets a single standard on how to write models.</p><p>Models in dbt are essentially tables or views in the database. When writing these models, dbt combines SQL with Jinja, and has additional YAML files for meta information. Jinja allows us to write powerful macros and stick to the DRY (Don’t Repeat Yourself) principle. dbt also takes care of the DDL creation, has automatic table level lineage and a convenient documentation feature. Additionally dbt offers a wide range of options to test the data. dbt allows us to quickly and sustainably write our models while simultaneously sticking to a production level standard.</p><p>Together with HomeToGo, our Data team has grown considerably over the last few years. From a group of 5 people who did it all 3 years ago, to a team of +30 with specialized roles embedded in different parts of the company. A lot of our analysts maintain their own pipelines, as they are closest to the business and know best what data is most valuable to drive decisions. While in the past speed was essential to keep things running and deliver insight, there’s a tipping point where quickly developed models do not scale anymore. Having <strong>a framework to standardize our transformations</strong> is key to reduce the risk of isolating ourselves in different parts of the company.</p><h3>Working our way upstream</h3><p>We started to implement dbt about six months ago. Our goal was to quickly reap the benefits of dbt and show its use to our stakeholders, so we started implementation of dbt at the end of our pipelines and steadily worked our way upstream, <strong>turning “dbt sources” into “dbt models”</strong>.</p><p>Some of the reasons we switched to dbt was to enable our stakeholders to get a deeper understanding of how a metric is being calculated and to provide documentation which lives close to the code for the models they consume. By starting with the models at the end of our pipeline and the ones we directly expose to our stakeholders, we immediately saw the benefits of having documented and well tested models, while simultaneously we built up experience on how to structure our project in the most efficient way.</p><p>While working our way upstream, we tried to create a <strong>single point of failure</strong> to align on definitions, reduce maintenance and allow for easy monitoring. This meant setting our definitions in a single place as far upstream as possible, causing all of our downstream models to consume the same definition. Although this sounds like a no-brainer, practice has shown that, in reality, this works differently. People make definitions quickly and according to their specific needs, which isolates a metric into a specific model. As time passes, some metrics provide valuable insight, while others are forgotten. As the amount of models continues to grow, you end up in a situation where definitions are all over the place in downstream tables and “technical debt” accumulates.</p><p>To structure our definitions, we’ve created 4 data layers (raw, derived, granular and aggregated). Each definition has its own objective and exclusively sources from the same layer or the one preceding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/0*FoRLmbxN_REivU_v" /><figcaption>Data layers</figcaption></figure><ol><li>The raw layer only contains the imports from our data generators and is the place where most of the data cleaning is done (timezone alignment, NULL checks etc.). A good example is our Snowplow data (click stream), booking data or Google Ads data.</li><li>All definitions are set in the derived layer. E.g. what is a “session”?, how do we measure “revenue”? And what is a “search interaction”?.</li><li>This causes us to only join derived tables in the “granular layer”, which is the first layer exposed to other teams and visualization tools outside of the data-warehouse.</li><li>The aggregate layer collects tables from the granular layer to provide more convenient and fast tables to interact with for important dashboards.</li></ol><p>dbt helps us to maintain this structure by providing automated table-level lineage. For example, it becomes very easy to spot which models of layer (3) and (4) still go back to raw tables (which they shouldn’t), and push the definitions further upstream in derived tables for them to be used in multiple models.</p><p>There are quite a few articles and ideas online about how to structure dbt projects and whether or not to cut a single project up into multiple projects. (See some good discussions <a href="https://discourse.getdbt.com/t/should-i-have-an-organisation-wide-project-a-monorepo-or-should-each-work-flow-have-their-own/666/2">here</a>, <a href="https://discourse.getdbt.com/t/how-to-configure-your-dbt-repository-one-or-many/2121">here</a> and <a href="https://medium.com/photobox-technology-product-and-design/practical-tips-to-get-the-best-out-of-data-building-tool-dbt-part-1-8cfa21ef97c5">here</a>.) We’re currently working in a single “mono-repo” which contains all of our dbt transformations. We keep it in a single project because we have a strong focus on bringing definitions closer together and we strive for cleaner lineage. As we continue to grow and develop, this might change — but right now there is no clear reason to start to work with separate repos.</p><p>The data layer structure creates an environment where if something breaks, we only need to fix it in one place. Everything downstream will automatically be updated. Additionally, we only need to test and monitor the metric/definition in one spot to assure it gets measured correctly in downstream tables.</p><p>We know that things usually break because of one of these factors:</p><ul><li>underlying input is changing</li><li>we make changes to our models which have unexpected side effects</li><li>our understanding of the input is changing</li></ul><p>In order to help us identify whether we have any “breaking” changes, we run tests using dbt focused on these factors.</p><h3>Testing our models</h3><p>We debated for some time what parts of data quality we want to cover and where. We want to make sure the data we provide is accurate, consistent, coherent, complete and delivered according to our SLA’s. At the same time, we want to enable our business teams to set up monitoring and run anomaly detection according to their needs, and ideally without the involvement of our Data teams!</p><p>As the Data team, we feel responsible for the quality of the data we deliver, but need to accept<strong> </strong>that<strong> a large part of the alerts which have value to our stakeholders are not in the control of the Data teams</strong>. Given that the data itself is correct, the most valuable alerts are often caused by externalities and business decisions. These alerts often have higher false positive rates and are usually not actionable by the Data teams.</p><p>With this in mind, we’ve decided to let dbt only handle tests which:</p><ol><li>are focussed on the accuracy, consistency and coherence of the data</li><li>are actionable by the Data teams</li><li>have a very low amount of false positives</li></ol><p>To help us validate the data on the above 3 points, we rely on <a href="https://github.com/calogica/dbt-expectations">dbt_expectations</a>. dbt_expectations is a dbt package which is inspired by <a href="https://greatexpectations.io/">Great Expectations</a>. We decided on dbt_expctations over Great Expectations because it has such nice integration with dbt. You add the tests in an already specified YAML and keep all meta-information, including the tests, in the same place. The main benefits of Great Expectations are the data profiling features, but as we want to focus on the three points above, the nicer integration of dbt_expectations with dbt is more important for us.</p><p>In the YAML files of all models we specified what kind of test we run and what we expect in these fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k0XaSuzVWz60pzcl" /><figcaption>Model YAML test example</figcaption></figure><p>Most of the tests are geared towards accuracy (are keys unique?), consistency (do table relations match?) and coherence (do pre-joined dimension fields contain the right dimensions?) of the data. The moment any of these tests fails, a Slack message is sent to dedicated Slack channels for Data teams.</p><p>In these Slack channels, we reply to the alerts with Emojis indicating:</p><ul><li>That we are actively looking into the problem</li><li>That the problem is resolved</li><li>That the problem currently can’t be resolved and our team needs to work together on next steps and a solution</li></ul><p>We run reports that give insight into the reactions on the alerts being sent to these channels. This creates a strong base because any alert thrown to the channel is a real issue that needs to be resolved quickly.</p><h3>Integration with Airflow</h3><p>For the orchestration of our pipelines we are running Airflow, which we described in more depth in our previous article <a href="https://engineering.hometogo.com/apache-airflow-at-hometogo-8f97a12b2be5">here</a>.</p><p>For the orchestration of our dbt models, we heavily rely on the <a href="https://docs.getdbt.com/reference/artifacts/manifest-json">manifest.json</a> generated by dbt. Inspired by <a href="https://www.astronomer.io/blog/airflow-dbt-1">this excellent series</a> from the Astronomer folk, we automate a large part of our Airflow DAG generation. We use the manifest to parse model dependencies, read all tests and, in the end, sync our data from our main Redshift cluster to our Analytical environment.</p><p>Each Airflow DAG exists in 3 separate <a href="https://www.astronomer.io/guides/task-groups">task groups</a>:</p><ol><li>dbt run tasks</li><li>dbt test tasks</li><li>sync tasks</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bZhbcmzh81CO2neX" /><figcaption>Airflow DAG graph</figcaption></figure><p>Each task group contains a set of functions where each function represents a single dbt model. This gives flexibility to (re)start each model through the Airflow UI and refresh all of its downstream dependencies from that task onwards! Additionally, the model already gets tested and syncs the moment that the single model is done running (meaning it doesn’t need to wait until all models are done running). The downside of having each model as a single Airflow task is that each model is called separately by the dbt run command which causes some overhead. However, the benefit of being able to restart any pipeline from the failed task onwards outweighs this, as execution time of our Redshift cluster is usually a larger portion of the total task run time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nhx5bNXCLKJiH0-h" /><figcaption>Airflow DAG graph</figcaption></figure><p>All models have at least a run and a test task. Some models also have a sync task, which triggers a custom python script to unload the model from our main Redshift cluster and copy it to our analytical environment. A breakdown of which models need to be synced where is maintained in the dbt models’ YAML file. This creates one single place to store all meta information of a model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*33rsn7Bb04NSpW-K" /><figcaption>Model YAML sync example</figcaption></figure><p>The dbt selectors define determine in which Airflow DAG a dbt model should run. After adding a new model or making changes to a model’s dependencies or meta information, we need to run a python script to parse the manifest.json and update two sets of JSON files per dbt selector.</p><p>The first JSON file defines the dependencies of all the models included by the selector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*4Pvtu4pQfIu5yGMI" /><figcaption>JSON model dependencies</figcaption></figure><p>The second JSON file contains the meta information from a model which we store in the same YAML file for each dbt model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/0*OtH2oZLe2JjB0VDr" /><figcaption>JSON model meta information</figcaption></figure><p>Updates to these files are required in Pull Requests to our Git Repo and are manual actions. Keeping these updates manual offers some flexibility in an otherwise completely automated process.</p><p>We have a single python script that creates the Airflow DAG’s by looping over the JSON files. Based on these 2 JSON files we dynamically create Airflow DAG’s. This means we only need to think about the tag for the model to define which Airflow DAG it belongs to. No changes are required for the individual Airflow DAG files.</p><p>As shown in the example above, models that do not pass the test do not get synced to the Analytical environment, and therefore are not exposed to our stakeholders. These <a href="https://medium.com/wrong-ml/taming-data-quality-with-circuit-breakers-dbe550d3ca78">circuit breakers</a> ensure that, if a test is not passed, we do not show any updates to our data. We want to be sure the data we expose is always correct, so we reduce the amount of questions about the quality of the data to increase the trust in the data. We ask ourselves one main question when we implement tests with dbt_expectations:</p><blockquote>Why test it if it’s not worth stopping the pipeline?</blockquote><p>Ultimately, the test we run with dbt_expectations should ensure that the data we provide is always 100% accurate, consistent and coherent. Other tools we have deployed take care of the tests for completeness, timeliness and anomaly detection, which by nature have a higher rate of false positives.</p><h3>To summarize</h3><p>dbt helps our Data teams by providing a framework to standardize a large part of the transformations in our data-warehouse. When we implement dbt, we start at the end of our pipeline and work our way upstream by turning dbt sources into dbt models. During the implementation, we aim to create a single point of failure using a clear data layer structure, which dbt helps to maintain. All of the data layers are tested with a focus on accuracy, consistency and coherence. We ensure the tests are actionable and have a very low amount of false positives. Orchestration is done by Airflow — each model is a single Airflow task and, according to selectors, is allocated to automatically generated Airflow DAGs.</p><p>If you are interested in learning more, we recommend these further readings:</p><ul><li><a href="https://about.gitlab.com/handbook/business-technology/data-team/platform/dbt-guide/">Gitlabs dbt guide</a></li><li><a href="https://medium.com/the-telegraph-engineering/dbt-a-new-way-to-handle-data-transformation-at-the-telegraph-868ce3964eb4">DBT: A new way to transform data and build pipelines at The Telegraph</a></li><li><a href="https://github.com/mattermost/mattermost-data-warehouse">Mattermost open data-warehouse Git repo</a></li><li><a href="https://medium.com/hashmapinc/dont-do-analytics-engineering-in-snowflake-until-you-read-this-hint-dbt-bdd527fa1795">Don’t Do Analytics Engineering in Snowflake Until You Read This (Hint: dbt)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ece067987267" width="1" height="1" alt=""><hr><p><a href="https://engineering.hometogo.com/dbt-at-hometogo-ece067987267">DBT at HomeToGo</a> was originally published in <a href="https://engineering.hometogo.com/">HomeToGo Data &amp; Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>