dbt-core icon indicating copy to clipboard operation
dbt-core copied to clipboard

[spike] Allow generic data tests to be documented

Open clrcrl opened this issue 4 years ago • 57 comments

Describe the feature

Currently, you can document pretty much everything but a data test - if you try, it fails on a parsing error. This ticket is for generic tests. A separate ticket addresses singular tests: https://github.com/dbt-labs/dbt-core/issues/9005

Acceptance criteria

  • You can add a description to a generic test
  • You can use a docs block to capture your test description
  • That description shows up in the docs site

Examples

version: 2

models:
  - name: orders
    columns:
      - name: order_id
        tests:
          - unique
            description: The order_id is unique for every row in the orders model
          - not_null
            description: '{{ doc("not_null_test") }}'

Concerns

  • adding documentation to tests will slow down parsing (full parse), particularly for really common tests like unique and not_null
  • We have special processing to speed up unique and not_null test parsing. Would that have to change?
  • Ensure the solution is performant

clrcrl avatar Jun 22 '20 13:06 clrcrl

I would say that for me a tests: label would imply all kind of tests, including schema tests, but looking at the current naming it looks like the most reasonable. Current names related to tests:

  • data tests are in the tests folder, not data-tests
  • in dbt_projectwe specify a folder for test-paths, not data-test-paths

RobMcZag avatar Oct 19 '20 14:10 RobMcZag

I know we've discussed putting schema tests in the tests directory instead of the macros directory, but I don't recall what the resolution of that was. Is that on the roadmap somewhere?

gshank avatar Jun 24 '21 15:06 gshank

@gshank @kwigley I'd like to use our discussion of this issue as a jumping-off point to discuss other test-related work we scoped out earlier this year, and to determine whether / which of these should go on the v1.0 list as well.

The ones that come to my mind are:

  • https://github.com/fishtown-analytics/dbt/issues/3234
  • https://github.com/fishtown-analytics/dbt/issues/3249
  • https://github.com/fishtown-analytics/dbt/issues/3250
  • https://github.com/fishtown-analytics/dbt/issues/3259
  • https://github.com/fishtown-analytics/dbt/issues/3348

All of those would represent a breaking change to some degree. There's ways we can offer backwards compatibility; easier for some, harder for others.

jtcohen6 avatar Jun 24 '21 15:06 jtcohen6

Work:

  • New parser for tests
  • Work will need to be done in partial parsing
  • Involve doc blocks (perf hit)

leahwicz avatar Jun 24 '21 17:06 leahwicz

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[bot] avatar May 11 '22 02:05 github-actions[bot]

I think the ticket activity doesn't reflect the demand for this feature, there has been at least 6 users asking about in on Slack this past year: https://getdbt.slack.com/archives/CBSQTAPLG/p1631304882432300

It might be because the wording used in the ticket has changed: schema test → generic test data test → singular test

I think custom tests are code as much as models and macros are, so documenting them is equally important.

@jtcohen6: I think a new tests: key in .yml files is exactly how we'd want to do this. Singular tests wouldn't be too hard. Generic tests would be trickier, since the good version (IMO) allows for templated descriptions that includes the values of {{ model }}, {{ column_name }}, and potentially other arguments.

IMO, having the static description as is in written in the YAML without replacing the values would already be nice and useful, the more complex version could be kept for later.

NicolasPA avatar Aug 30 '22 10:08 NicolasPA

I came to +1 this post. Looking forward to support for documenting Singular Tests. Thanks!

jeff-skoldberg-ct avatar Dec 07 '22 19:12 jeff-skoldberg-ct

+1 from me too.

gnilrets avatar Jan 21 '23 00:01 gnilrets

+1 from my side as well. It's quite important to be able to document what a test does.

ChristianP89 avatar Jan 26 '23 21:01 ChristianP89

+1 from me as well.

nbkrd1 avatar Jan 30 '23 13:01 nbkrd1

+1 from me too.

nbllh1 avatar Jan 30 '23 13:01 nbllh1

+1

GeorgeHC97 avatar Feb 09 '23 11:02 GeorgeHC97

+1

ghost avatar Feb 10 '23 10:02 ghost

+1

minhnhat992 avatar Feb 13 '23 02:02 minhnhat992

+1

dvanbolt avatar Mar 10 '23 14:03 dvanbolt

+1

trevor-petach avatar Mar 13 '23 20:03 trevor-petach

+1

bethanyhipple-dbtlabs avatar Mar 16 '23 23:03 bethanyhipple-dbtlabs

+1

moralescastillo avatar Mar 20 '23 13:03 moralescastillo

+1 from me too.

dennisgera avatar Mar 20 '23 20:03 dennisgera

+1

jfreels avatar Mar 20 '23 20:03 jfreels

+1

ipcleary avatar Mar 20 '23 20:03 ipcleary

+1 from me

culpgrant avatar Mar 22 '23 20:03 culpgrant

+1 please

mwbong avatar Mar 29 '23 08:03 mwbong

+1

simonhoerdumbonde avatar Apr 19 '23 16:04 simonhoerdumbonde

+1

scwin813 avatar May 04 '23 13:05 scwin813

+1 please

sedgar avatar May 28 '23 20:05 sedgar

+1 please!

AnotherGuitar avatar May 31 '23 17:05 AnotherGuitar

The compiler doesn't complain when I set the description in a singular test's config block, but when the docs are rendered, it says "This test is not currently documented". 🤔

When you get to this, I'd like you to add test-paths to the default doc-paths so that I don't need to do anything weird to get the compiler to pick up the doc blocks for my tests.

kgeis avatar Jun 09 '23 20:06 kgeis

+1

rd144 avatar Jul 04 '23 21:07 rd144

+1 from me too. Given that tests are included in the docs, and that it's just good practice, it should be possible to document singular tests.

mrkjones79 avatar Jul 05 '23 14:07 mrkjones79