Published: By: Max Dyrhage, Max Krog Reading time: 8 min

Analytics engineering with dbt

Between your data team and insights, data needs to be transformed, cleaned and quality-assured. That task – right between the data team and the analysts – has long lacked a clear owner.

In response to this problem, analytics engineering has emerged as a role, and dbt as a popular tool. Here we go through both.

In recent years, many have invested heavily in their data and analytics capabilities. Data engineers have been hired or brought in as consultants, data pipelines have been set up, and data warehouses and data lakes have been filled with large amounts of data.

Everyone has done their job. Now we finally have the data in. Hook up some visualisation interface (Tableau seems popular) and start analysing! Now we will become data-driven! Well, not quite.

The journey towards the data-driven, experimenting and always-learning future that many companies dream of often gets stuck today between the data team and the consumers (data analysts/scientists/data-driven products).

Before your data is useful for decision-makers, products and analytically minded employees, in almost all interesting cases it needs to be transformed and cleaned a few more times. It needs to be adapted to its context, made available and quality-assured to create value.

Challenges with how we work with data today

Raw data is not ready to be analysed

To make sense of all the data you are sitting on, it needs to be cleaned, enriched and compiled. This task is often placed on data engineers, but it quickly becomes obvious that it does not generate much value per krona. They are a bit too far from the business and often only half hit the mark with the aggregates they produce. There always seems to be some dimension or metric missing. When your data engineering team already has its hands full, product owners, analysts, data scientists and others start asking questions that your data is not yet ready to answer.

Question: Give me all users who left the service in the last month.

Answer: It’s in the (data) lake.

Data cleaning is a big time thief

It is almost becoming a truism that 80% of the working time of a data analyst/scientist goes on troubleshooting and cleaning data. If that is not true for you right now, there is a big risk that you are sitting on a burden of scheduled jobs that were set up to put out urgent analytics fires and then stayed. When something needs to be added, changed or explained, you just have to jump into the algae-blooming data lake.

Shortcuts become detours

There is a wealth of paths and tools for getting more impact and quality from your data. As with much else, the choices you make matter for your current and above all future ability to deliver value. It is a balancing act between fast value-creating hacks and long-term scalable solutions.

Quite rightly, many start by investing in filling their data platforms with data. After that, they rely on some reasonably powerful visualisation interface to do the job of extracting the insights. Unfortunately, that is rarely the case.

Often, internal friction arises between a business that wants insights preferably yesterday and data teams that want to build stable and scalable.

In the frustration of waiting, people with more or less knowledge of data and context start solving problems in their own ways. Home-made setups, scheduled jobs and aggregates pop up here and there around your data.

It is a fantastic effort that creates plenty of value in the short term. Unfortunately, it comes at a cost in the longer term. Now you are left with scattered, inconsistent data that says different things depending on who you ask. On top of that, a dependency on individuals is created, where only a few people know how different metrics have been hacked together.

Of course, it should not be like that. Naturally, this has been a hotly debated topic among data nerds in recent years.

From data engineering to analytics engineering

Okay, so we need to find more efficient ways of transforming our data so that more people can use it. We also need to do it in a stable and scalable way. So how do we do that?

One solution many turn to is looking at how similar problems have been solved in traditional software development. Most analysts know enough SQL to self-serve the most complex questions.

The cornerstones of democratising data:

  • Relevant and adapted to context
  • Available when business-critical decisions are made
  • Quality-assured
  • Consistent and transparent across the organisation

It is absolutely right to take a lean approach and in some cases build quick solutions before scalable models. Removing fast experiments altogether is definitely not the way forward. New ideas for metrics and analyses should of course be encouraged. But as soon as you see value, the last two points above become critical to enable recurring value in the longer term.

Want to hear more about how to lay the cornerstones for democratising your data? Sign up for our webinar!

Quality creates trust

Without quality in your data, trust is quickly lost. The wet blanket on your data-driven momentum is hard to undo. Analytics engineering makes sure that the data underlying your reports, dashboards, analyses and machine learning is correct and quality-assured.

Collaborate for consistent data

An analytics engineer collaborates with data engineers, scientists and analysts in different ways. With the data team, problems concerning infrastructure and which data is collected can be discussed and optimised. With scientists and analysts, the data’s ability to drive the business forward is constantly pushed. More or less together, these two roles/functions work to quality-assure and fine-tune the transformation of the data.

Together with data scientists and analysts, an analytics engineer works to translate data modelling needs into best practices from software development. Beyond that, the aim is to find efficiencies in the form of tools and interfaces so that analysts can focus on value-creating insight hunting.

You do not want to be in the position where the same metric is shown differently depending on who in the organisation you ask. To get consistent data, you need to collaborate across the organisation. By applying the best of how we collaborate in “regular” product development, you take steps towards democratising your data and faster insights.

A tool that covers and eases large parts of the gaps analytics engineering wants to solve is dbt (data build tool). Several of Signific’s clients (and companies such as HubSpot, GitLab and The Telegraph, among others) use dbt.

dbt. Huh? Yeah. What is it good for?

dbt was developed by Fishtown Analytics and over the last 2–3 years has emerged as the new hot thing in what we call analytics engineering. Those of us at Signific who have used it can only join the chorus of praise.

The main function of dbt is to take code, compile it into SQL and run it against your database. That in itself sounds pretty basic, but there is more to it.

dbt takes an almost holistic approach to the T in ETL. With dbt, companies can set up the transformation of their data with queries. On top of that, the flow of queries is orchestrated in a very smooth way. It is a relatively new tool, but more than 300 companies (and several Signific clients) are already benefiting from the advantages and possibilities dbt provides.

Where dbt does a job in your data transformation (light blue)

Testable, version-controlled and documented transformation

One of the best things about dbt is how easy it is to treat the transformation as a real product.

With dbt’s so-called models you can split your jobs into a clear structure. Your entire set-up is version-controlled like a regular code base. That makes it much easier to get an overview of and to collaborate on than scattered jobs and hacks, which are often the first solution.

dbt also makes it possible to set up tests on your transformation flow. When business-critical decisions are to be made, you want to be sure the data has been processed correctly. When the dashboard or chart in the presentation shows incorrect data, it is already too late. dbt offers ready-made tests for your schema and an easy way to set up more specific data tests.

The structure and version control create much clearer documentation of what exists and what has been done (if you set it up correctly). Another nice feature dbt offers is being able to generate a visualisation of your transformation flow.

Directed acyclic graph (DAG) of how the transformation fits together (Photo: getdbt.com)

Collaborate with SQL as the interface

Because dbt is based on setting up SQL for your transformation, barriers to collaboration between data teams and others are reduced. SQL is something many analysts and data scientists know, and so do developers. At least to a level where you can start collaborating, sharing knowledge and building together.

Powerful with your cloud platform

As a dbt user, you focus mainly on building models (writing queries) to do the transformation that suits your data and business. You do not have to write boilerplate code to create tables and views. dbt also works out the order in which your models are executed for you.

dbt takes your models and places them as objects in your data warehouse. The simplicity and structure, without compromising on the power and scalability you get in the cloud. We have mainly run dbt against Google Cloud Platform and BigQuery ourselves, but there is also support for Snowflake, Redshift, Postgres and others

Open Source

To top it all off, dbt is also open source. So it is free to get started, but also easily accessible and constantly developed by Fishtown and other contributors. As mentioned, more and more companies are already moving parts of their transformation to dbt. With more and more users and a lively community, there is good reason to believe dbt is here to stay.

Drawbacks and alternatives

Of course, dbt is not the solution to all your data problems. There are both drawbacks and other alternatives.

Being SQL-based is in many cases an advantage, but it still requires a fairly good knowledge of SQL to succeed. Knowledge of source control is also needed to make it work. Tools like Looker’s PDTs and Tableau to some extent allow people without SQL skills to set up parts of your transformation.

It also only covers the T (transformation) in ETL. You need other solutions both to extract and to load the data you have finished processing. Other companies and open source alternatives are starting to pop up in the E and the L too, but dbt is not one of them. Airbyte and Hightouch are two alternatives we are testing right now, but there are almost as many alternatives as there are data-hungry companies.