Skip to content

Instantly share code, notes, and snippets.

View portovep's full-sized avatar

Pablo Porto portovep

View GitHub Profile
@portovep
portovep / body_mass_indexes_component_test.sql
Created May 31, 2023 07:26
Example of a dbt component test
# body_mass_indexes_component_test.sql
{{ config(tags=['unit-test', 'component-test']) }}
{% call dbt_unit_testing.test ('body_mass_indexes',
'it should calculate the body mass index for users with weight and height measurements') %}
{% call dbt_unit_testing.mock_source('gym_app', 'raw_weight', {"input_format": "csv"}) %}
date,user_id,weight,measurement_unit
{{ config(tags=['unit-test', 'unit-tests']) }}
{% call dbt_unit_testing.test ('int_weight_measurements_with_latest_height',
'it should enrich weight measurement with latest height measurement') %}
{% call dbt_unit_testing.mock_ref ('stg_gym_app__weight') %}
select
to_date('2022-09-01', 'YYYY-MM-DD') as created_date,
1 as user_id,
82.50 as weight
@portovep
portovep / int_weight_measurements_with_latest_height.sql
Last active May 30, 2023 14:01
Example of a dbt intermediate model
with
height as (
select * from {{ dbt_unit_testing.ref('stg_gym_app__height') }}
),
weight as (

Keybase proof

I hereby claim:

  • I am portovep on github.
  • I am portovep (https://keybase.io/portovep) on keybase.
  • I have a public key ASAWXs6TSLfkq8PR7vOacYRNs-l4gMml-F2QGI35fBSCuwo

To claim this, I am signing this object: