In this lesson we will:

  • Introduce dbt, the leading tool for data transformations within the Modern Data Stack;
  • Look at an example of a dbt model;
  • Explain some of the high level benefits of using dbt.

Generic Tests

In an earlier lesson we saw how we can use dbt properties to apply tests to the models that we create.

As we discussed, it is possible to extend the out of the box tests and write our own parameterised tests. These tests could check for something generic about the data, for instance that values fall in a certain expected range, or something more specific to your business domain.

Once written, generic tests are accessed as properties:

models:
  - name: orders
    columns:
      - name: order_category
        tests:
          - is_available_order_category

Developing A Generic Test

As per everything else in dbt, our generic tests will be defined in SQL and Jinja. However, this is slightly more involved than some areas of dbt because we need to to make our tests parameteried such that they can be reused across our project.

Generic tests would typically be stored in the _tests/model_folder. The filename that you use is used as the name of the test:

is_capital_city

This test could then be applied to a model in the yml.

Next Lesson:
12

Configuring dbt Profiles

In this lesson we will explain the dbt profile system and best practices for managing profiles for maintainable code.

0h 15m




Work With The Experts In Real-Time Analytics & AI

we help enterprise organisations deploy powerful real-time Data, Analytics and AI solutions based on ClickHouse, the worlds fastest open-source database.

Join our mailing list for regular insights:

We help enterprise organisations deploy advanced data, analytics and AI enabled systems based on modern cloud-native technology.

© 2024 Ensemble. All Rights Reserved.