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

Configurable description in yaml config for generic tests #3249

Closed
kwigley opened this issue Apr 12, 2021 · 8 comments
Closed

Configurable description in yaml config for generic tests #3249

kwigley opened this issue Apr 12, 2021 · 8 comments
Labels
dbt tests Issues related to built-in dbt testing functionality duplicate This issue or pull request already exists enhancement New feature or request stale Issues that have gone stale

Comments

@kwigley
Copy link
Contributor

kwigley commented Apr 12, 2021

Describe the feature

Add the ability to define descriptions in yaml files. Support the ability to use the rendered values of the test args ({{ model }} and {{ column_name }} by default)

Consider the following example:

# macros/reusable_tests.sql
{% test not_null(model, column_name), adapter = 'default' %}

    select * from {{ model }}
    where {{ column_name }} is null

{% endtest %}

# macros/schema.yml
tests:
 - name: not_null
   adapter: default
   description: "Assert that {{ column_name }} is not null in {{ model }}"
   args:
     - name: model
       description: "The model to test"
     - name: column_name
       description: "The column or expression to test"

Additional context in #1173.

@kwigley kwigley added enhancement New feature or request dbt tests Issues related to built-in dbt testing functionality labels Apr 12, 2021
@jtcohen6
Copy link
Contributor

In an ideal world, all arguments to the generic test could be in scope when resolving the description. So, for instance, {{ values }} for an accepted_values test. If that's too tricky, I think {{ model }} + {{ column_name }} make for an excellent first cut.

Note that one-off/bespoke tests should also be able to have descriptions defined (#2578), but those wouldn't have the same kinds of variables in context—just doc blocks, like any other resource description.

@jtcohen6
Copy link
Contributor

jtcohen6 commented May 5, 2021

We've discussed using this description, if available / in lieu of the test unique_id, to construct the failure message for stdout logging, and to store that same message in run_results.json for better metadata. In concert with the changes in #3258 + #3321, we've imagined:

Completed with 1 error and 1 warning:

Failure in test: Ensure column `fun` in `my_model` meets my custom criteria
  Found 1 failing record, expected 0.

  compiled SQL at target/compiled/my_project/models/schema.yml/schema_test/my_custom_generic_my_model_fun.sql

Warning in test: my_custom_bespoke
  Calculated failure is 1, which is >0.

  compiled SQL at target/compiled/my_project/tests/my_custom_bespoke.sql

Done. PASS=0 WARN=1 ERROR=1 SKIP=0 TOTAL=2

@kwigley Is that something you'd want to tackle in this issue / #3302, or should we open up a separate issue?

@jtcohen6
Copy link
Contributor

jtcohen6 commented May 6, 2021

Update on the thought above: I'm less sure about whether we need to include that synthesized message in run_results.json, since the description will be in the manifest.json, and the two can be joined together on the unique_id.

@github-actions
Copy link
Contributor

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 remove the stale label or comment on the issue, or it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Dec 28, 2021
@github-actions github-actions bot closed this as completed Jan 4, 2022
@joellabes
Copy link
Contributor

I still want this! Mostly for the aliasing reasons discussed in #3815

@joellabes joellabes reopened this Jan 4, 2022
@joellabes joellabes removed the stale Issues that have gone stale label Jan 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2022

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 remove the stale label or comment on the issue, or it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Jul 5, 2022
@github-actions
Copy link
Contributor

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

@dbeatty10
Copy link
Contributor

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2024
@dbeatty10 dbeatty10 added the duplicate This issue or pull request already exists label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dbt tests Issues related to built-in dbt testing functionality duplicate This issue or pull request already exists enhancement New feature or request stale Issues that have gone stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants