Skip to main content

Introduction for dbt users



All dbt projects are also valid metriql projects. metriql creates datasets from all your dbt models, seeds, and sources if you have meta.metriql property for these dbt resources. The only missing part is the metric (aka measure) definitions. metriql makes use of dbt's meta properties so you can model your data by adding extra properties to the meta field.

metriql automatically creates dimensions for each column definitions in your resource files and you can add your custom metric definitions under meta property as follows:

models:
- name: customers
meta:
metriql
columns:
- name: country_code
meta:
metriql.dimension:
type: string
- name: city
meta:
metriql.dimension:
type: string
- name: total_customers
description: total number of customers defined as count(*) in sql
meta:
metriql.measure:
aggregation: sum

In addition to column mapping, you can also create custom measures and dimensions by defining them under meta or the model:

models:
- name: customers
meta:
metriql:
measures:
total_rows:
aggregation: count
dimensions:
full_location:
sql: CONCAT({TABLE}.country, {TABLE}.city)
type: string

Congratulations, you created your first dataset in dbt! Now, we need to use metriql CLI to expose out dataset:

You can follow the links below as the next step: