Introduction for dbt users
#
Metriql CLIAll 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: customersmeta:metriqlcolumns:- name: country_codemeta:metriql.dimension:type: string- name: citymeta:metriql.dimension:type: string- name: total_customersdescription: total number of customers defined as count(*) in sqlmeta: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: customersmeta:metriql:measures:total_rows:aggregation: countdimensions: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:
- Run
metriql serve
command.
You can follow the links below as the next step:
- Learn more about the data modeling concept in Creating Datasets.
- See full reference of dataset properties.
- Start consuming your data.