-- This generates a query to compare row by row two versions of the same table.
-- It then classifies the results into three categories:
-- - identical: the rows are identical
-- - different: the rows are different
-- - missing: the rows are missing from one of the tables
-- It then returns a table with the results.

-- Example usage:
{% set old_query %}
    select * from suno_prod.prod.fact_credit_topup
    WHERE 1=1
    AND {{ partition_filter_daily('p_date') }}
{% endset %}

{% set new_query %}
    select * from {{ ref('fact_credit_topup') }}
    WHERE 1=1
    AND {{ partition_filter_daily('p_date') }}
{% endset %}


{{ 
  audit_helper.compare_and_classify_query_results(
    old_query, 
    new_query, 
    primary_key_columns=['id'], 
    columns=['user_id', 'user_uid', 'billing_provider', 'purchased_on_platform', 'provider_customer_id', 'provider_transaction_id', 'n_credits', 'purchased_ts_utc', 'provider_product_id', 'provider_product_name', 'amount_usd', 'amount_local', 'currency_code', 'p_date']
  )
}}
