Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update code example for fail_calc #5221

Merged
merged 1 commit into from
Apr 3, 2024
Merged

Update code example for fail_calc #5221

merged 1 commit into from
Apr 3, 2024

Conversation

dbeatty10
Copy link
Contributor

@dbeatty10 dbeatty10 commented Apr 3, 2024

Preview

What are you changing in this pull request and why?

The current code example does not always work and may raise an error like this:

14:01:53  None is not of type 'integer'
14:01:53  
14:01:53  Failed validating 'type' in schema['properties']['failures']:
14:01:53      {'type': 'integer'}
14:01:53  
14:01:53  On instance['failures']:
14:01:53      None

As described in dbt-labs/dbt-core#4248, it's known that:

  • tests whose fail_calc is a sum() function raises an error when the test produces no rows at all

Well, that explains why the code example doesn't work!

Jerco described two options for dealing with this:

  1. rewrite the test query, to ensure it always returns at least one row
  2. rewrite the fail_calc, to handle the case in which no rows are returned

This PR adopts the 2nd option and updates the code example to handle the case in which no rows are returned.

Checklist

  • Review the Content style guide so my content adheres to these guidelines.
  • I've verified that the updated code example works

Copy link

vercel bot commented Apr 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview Apr 3, 2024 2:03pm

@dbeatty10 dbeatty10 marked this pull request as ready for review April 3, 2024 14:03
@dbeatty10 dbeatty10 requested a review from a team as a code owner April 3, 2024 14:03
@github-actions github-actions bot added content Improvements or additions to content size: x-small This change will take under 3 hours to fix. labels Apr 3, 2024
@nghi-ly nghi-ly merged commit 017526f into current Apr 3, 2024
15 checks passed
@nghi-ly nghi-ly deleted the dbeatty10-patch-4 branch April 3, 2024 14:36
mirnawong1 added a commit that referenced this pull request Apr 9, 2024
…no rows at all (#5246)

[Preview](https://docs-getdbt-com-git-dbeatty10-patch-1-dbt-labs.vercel.app/reference/resource-configs/fail_calc)

## What are you changing in this pull request and why?

Follow-up to #5221

resolves #918

See also: dbt-labs/dbt-core#4248

## Checklist
- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content size: x-small This change will take under 3 hours to fix.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants