Audit environment variables

Paradime provides a set of system environment variables that can be added to your dbt™️ models to inject metadata at run time to add more information to your materialized tables in your data warehouse.

These can be used to help identify which schedules run relates to a given row of data in your tables.

Vairable nameexample

PARADIME_WORKSPACE_NAME

jaffle_shop

PARADIME_SCHEDULE_NAME

hourly_run

PARADIME_SCHEDULE_RUN_ID

39828

PARADIME_SCHEDULE_RUN_START_DTTM

2022-07-15 21:50:21.268372

PARADIME_SCHEDULE_TRIGGER

one of:

  • scheduler

  • manual from user@email.com

  • API

  • TURBO CI

PARADIME_SCHEDULE_GIT_SHA

4a9fcff9277dfabd447157dea86dd7fdbd17d6f8

Include env variables in your dbt™️ models to audit your runs

Include any of the above variable in your dbt™️ models. At run time, for each row of data in your data warehouse tables, with metadata to help audit each row.

{% set payment_methods = ['credit_card', 'coupon', 'bank_transfer', 'gift_card'] %}

with orders as (

    select * from {{ ref('stg_orders') }}

),

order_payments as (

    select * from {{ ref('order_payments') }}

),

final as (

    select
        orders.order_id,
        orders.customer_id,
        orders.order_date,
        orders.status,
        

        {% for payment_method in payment_methods -%}

        order_payments.{{payment_method}}_amount,

        {% endfor -%}

        order_payments.total_amount as amount

    from orders

    left join order_payments using (order_id)

)

select 

    *,
    -- Inject the audit metadata if available, otherwise use "manual"
    '{{ env_var("PARADIME_WORKSPACE_NAME", "manual") }}' as _audit_workspace_name,
    '{{ env_var("PARADIME_SCHEDULE_NAME", "manual") }}' as _audit_schedule_name,
    '{{ env_var("PARADIME_SCHEDULE_RUN_ID", "manual") }}' as _audit_schedule_run_id,
    '{{ env_var("PARADIME_SCHEDULE_RUN_START_DTTM", "manual") }}' as _audit_schedule_run_start_dttm,
    '{{ env_var("PARADIME_SCHEDULE_TRIGGER", "manual") }}' as _audit_schedule_trigger,
    '{{ env_var("PARADIME_SCHEDULE_GIT_SHA", "manual") }}' as _audit_schedule_git_sha,

from final

Last updated