Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

dbt_utils.equal_rowcount error when comparing tables with 0 rows #973

Open
1 of 5 tasks
i-125 opened this issue Dec 25, 2024 · 0 comments · May be fixed by #974
Open
1 of 5 tasks

dbt_utils.equal_rowcount error when comparing tables with 0 rows #973

i-125 opened this issue Dec 25, 2024 · 0 comments · May be fixed by #974
Labels
bug Something isn't working triage

Comments

@i-125
Copy link

i-125 commented Dec 25, 2024

Describe the bug

When using dbt_utils.equal_rowcount, comparing tables with 0 rows causes an error as the function returns null instead of a valid result.

Steps to reproduce

  1. Create two models with 0 rows in each.
  2. Implement a test using dbt_utils.equal_rowcount to compare the two models.
  3. Run the test.

Expected results

The test should return 0 as the row count for both models matches (0 rows in each).

Actual results

The test returns null instead of 0, causing an error.

03:25:12  Finished running 1 test, 2 project hooks in 0 hours 0 minutes and 4.11 seconds (4.11s).
03:25:13  
03:25:13  Completed with 1 error and 0 warnings:
03:25:13  
03:25:13    None is not of type 'integer'

Failed validating 'type' in schema['properties']['failures']:
    {'type': 'integer'}

On instance['failures']:
    None
03:25:13  
03:25:13  Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1

Screenshots and log output

System information

The contents of your packages.yml file:

  • package: dbt-labs/dbt_utils
    version: 1.1.1

Which database are you using dbt with?

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

The output of dbt --version:

Core:
  - installed: 1.8.6
  - latest:    1.9.1 - 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:
  - bigquery: 1.8.2 - Update available!

Additional context

{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}

Are you interested in contributing the fix?

Sure! I would replace the implementation with something like:
{{ config(fail_calc = 'coalesce(sum(diff_count), 0)') }}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant