Skip to content

Commit

Permalink
Fix docs. Make statuses friendlier
Browse files Browse the repository at this point in the history
  • Loading branch information
clrcrl committed Sep 26, 2019
1 parent 898dd38 commit 2e943ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ This macro is useful when:
* You've used the `compare_queries` macro (above) and found that a significant
number of your records don't match.
* So now you want to check if a particular column is problematic.

This macro will return a query, that, when executed, summarizes the number of
records that match perfectly:

| match_status | count |
| --------------------------- | ------ |
| ✅: perfect match | 37,721 |
| ✅: both are null | 5,789 |
| 🤷: missing from b | 25 |
| 🤷: value is null in a only | 59 |
| 🤷: value is null in b only | 73 |
| 🙅: ‍values do not match | 4,064 |

### Usage:
```
{# in dbt Develop #}
Expand All @@ -122,22 +136,13 @@ number of your records don't match.
{% do audit_results.print_table() %}
```
This will give you an output like:
```
Comparing column "status"
| match_status | count |
| ----------------------- | ------ |
| ✅: perfect match | 37,721 |
| 🤷: missing from b | 25 |
| 🙅: ‍values do not match | 4,064 |
```

Usage notes:
**Usage notes:**
* `primary_key` must be a unique key in both tables, otherwise the join won't
work as expected.


### Advanced usage
### Advanced usage:
Got a wide table, and want to iterate through all the columns? Try something
like this:
```
Expand Down
4 changes: 2 additions & 2 deletions macros/compare_column_values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ joined as (
when a_query.{{ column_to_compare }} is null and b_query.{{ column_to_compare }} is null then '✅: both are null'
when a_query.{{ primary_key }} is null then '🤷: ‍missing from a'
when b_query.{{ primary_key }} is null then '🤷: missing from b'
when a_query.{{ column_to_compare }} is null then '🤷: exists, but null in a'
when b_query.{{ column_to_compare }} is null then '🤷: exists, but null in b'
when a_query.{{ column_to_compare }} is null then '🤷: value is null in a only'
when b_query.{{ column_to_compare }} is null then '🤷: value is null in b only'
when a_query.{{ column_to_compare }} != b_query.{{ column_to_compare }} then '🙅: ‍values do not match'
else 'unknown' -- this should never happen
end as match_status,
Expand Down

0 comments on commit 2e943ac

Please sign in to comment.