dbt-labs / dbt-audit-helper

Useful macros when performing data audits

Home Page:https://hub.getdbt.com/dbt-labs/audit_helper/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong example query in documentation for `compare_column_values`

Enjow opened this issue · comments

commented

Describe the bug

The example query of how to use compare_columns_values is wrong and will give an error if copying.
Missing a

{{ audit_query }}

https://github.com/dbt-labs/dbt-audit-helper#compare_column_values-source

Steps to reproduce

Copy paste the example query from https://github.com/dbt-labs/dbt-audit-helper#compare_column_values-source

Expected results

Test will run without errors.

Actual results

Copy pasting and tweaking the examplequery will give the output of

Database Error in test <test name> (<path to test>.sql)
Syntax error: Unexpected ")" at [21:5]

Screenshots and log output

System information

The contents of your packages.yml file:

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

<output goes here>

The operating system you're using:

The output of python --version:

Additional context

Are you interested in contributing the fix?

This is fairly straight forward. Entire fix can be done by replacing the code snippet with:

{# in dbt Develop #}

{% set old_etl_relation_query %}
    select * from public.dim_product
    where is_latest
{% endset %}

{% set new_etl_relation_query %}
    select * from {{ ref('dim_product') }}
{% endset %}

{% set audit_query = audit_helper.compare_column_values(
    a_query=old_etl_relation_query,
    b_query=new_etl_relation_query,
    primary_key="product_id",
    column_to_compare="status"
) %}

{{ audit_query }} 

{% set audit_results = run_query(audit_query) %}

{% if execute %}
{% do audit_results.print_table() %}
{% endif %}

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.