-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I'm interested in prototyping the following proposal.
Goal
Enable the DIFF operator within a dbt project.
Implementation proposal
- Create a suite of dbt macros that mimic the SQL generated within datools/explanations.py
diff()macro as the main interface- Result is a relation like this:

Potential syntax
with
this_week as (
select *
from {{ ref("logs") }}
where
crash = true
and timestamp between '2018-08-28' and '2018-09-04'
),
last_week as (
select *
from {{ ref("logs") }}
where
crash = true
and timestamp between '2018-08-21' and '2018-08-28'
)
{{ datools.diff(this_week, last_week, on=["app_version", "device_type", "os"], compare_by="risk_ratio", threshold="2.0", support="0.05", max_order="1") }}Examples of dbt macros
These two dbt packages contain macros that might be useful for inspiration:
- https://github.com/dbt-labs/dbt-utils/tree/main/macros
- https://github.com/calogica/dbt-expectations/tree/main/macros
For example:
Metadata
Metadata
Assignees
Labels
No labels