dbt-labs / dbt-audit-helper

Useful macros when performing data audits
https://hub.getdbt.com/dbt-labs/audit_helper/latest/
Apache License 2.0
329 stars 40 forks source link

`compare_all_columns` has a tough time with null values #68

Closed leoebfolsom closed 1 year ago

leoebfolsom commented 1 year ago

Describe the bug

Currently, the compare_all_columns macro does a poor job of distinguishing between missing data and null values.

We must check to see if the primary key exists in both of the two tables to determine whether the value in that table is null or missing.

Steps to reproduce

Incorrect handling of missing rows leading to wrong perfect_match value

Incorrect comparison of null to not null leading to wrong conflicting_valuesvalue

Expected results

Incorrect handling of missing rows leading to wrong perfect_match value

Incorrect comparison of null to not null leading to wrong conflicting_valuesvalue

Actual results

The opposite of what's expected.

Screenshots and log output

System information

The contents of your packages.yml file:

packages:
  - package: dbt-labs/audit_helper
    version: 0.7.0

Which database are you using dbt with?

The output of dbt --version:

Core:
  - installed: 1.4.1
  - latest:    1.4.5 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - snowflake: 1.4.1 - Update available!

  At least one plugin is out of date or incompatible with dbt-core.
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

The operating system you're using:

Screenshot 2023-03-27 at 14 56 23

The output of python --version:

Python 3.9.6

Additional context

Are you interested in contributing the fix?

Yes!

leoebfolsom commented 1 year ago

I'm not sure if there's a more official way of connecting this issue to the PR I opened, but here it is! [IN PROGRESS] https://github.com/dbt-labs/dbt-audit-helper/pull/67

leoebfolsom commented 1 year ago

Fixed by: