Skip to content

Instantly share code, notes, and snippets.

View arimbr's full-sized avatar
🏠
Working from home

Ari Bajo arimbr

🏠
Working from home
View GitHub Profile
columns:
- name: payment_method
tests:
- not_null:
where: user_status = 'activated'
meta:
description: "Validate that each activated user has a payment method. If fails, there is an issue with the application billing table or the job that syncs it"
owner: '@Jonh Smith'
channel: 'application_team_data_alerts'
models:
- name: payments
tests:
- dbt_utils.expression_is_true:
expression: "inbound_amount = payout_amount + refund_amount"
- dbt_utils.expression_is_true:
expression: "inbound_amount = inbound_cash_amount + inbound_credit_amount"
{% macro default__test_relationships(model, column_name, to, field) %}
with child as (
select {{ column_name }} as from_field
from {{ model }}
where {{ column_name }} is not null
),
parent as (
select {{ field }} as to_field
columns:
- name: activated_at
tests:
- not_null:
where: "user_status = 'activated'"
- name: payment_method
tests:
- accepted_values:
values: ['credit_card', 'gift_card']
where: "user_status = 'activated'"
models:
- name: login_events
config:
elementary:
timestamp_column: 'loaded_at'
columns:
- name: user_name
tests:
- elementary.column_anomalies:
column_anomalies:
models:
- name: login_events
config:
elementary:
timestamp_column: "loaded_at"
tests:
- elementary.dimension_anomalies:
dimensions:
- event_type
- country_name
models:
- name: login_events
tests:
- elementary.volume_anomalies:
timestamp_column: “loaded_at”
where_expression: sql expression
anomaly_sensitivity: int
anomaly_direction: [both | spike | drop]
days_back: int
backfill_days: int
models:
- name: login_events
tests:
- elementary.freshness_anomalies:
timestamp_column: "loaded_at"
anomaly_sensitivity: 2
models:
- name: login_events
columns:
- name: loaded_at
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
sources:
- name: jaffle_shop
database: raw
freshness: # default freshness
warn_after: {count: 12, period: hour}
error_after: {count: 24, period: hour}
loaded_at_field: _etl_loaded_at