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

[CT-2430] [Freshness test tags] Please add tags to freshness tests #7395

Closed
3 tasks done
mddataminr opened this issue Apr 18, 2023 · 3 comments
Closed
3 tasks done

[CT-2430] [Freshness test tags] Please add tags to freshness tests #7395

mddataminr opened this issue Apr 18, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@mddataminr
Copy link

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

I would like Freshness tests to be tagged and then allow running specific tags using some sort of a select query. This would allow for more granular running of tests.

Describe alternatives you've considered

Discontinue using Freshness tests and instead write a custom macro

Who will this benefit?

Potential benefits:

  • Tests can be grouped by SLA priority, allowing for better on call alert handling
  • This would save us compute costs because if we have a long failure period, we don't need to run the tests as often as others
  • Would speed up development cycles if we can run only tests related to the changes in the feature being implemented

Are you interested in contributing this feature?

I'm new to the code in this project. If someone can point me in the right direction I can make the changes

Anything else?

No response

@mddataminr mddataminr added enhancement New feature or request triage labels Apr 18, 2023
@github-actions github-actions bot changed the title [Freshness test tags] Please add tags to freshness tests [CT-2430] [Freshness test tags] Please add tags to freshness tests Apr 18, 2023
@dbeatty10
Copy link
Contributor

Thanks for proposing this @mddataminr !

Are you thinking something like this?

models/_sources.yml

version: 2

sources:
  - name: dbt_dougie_fresh
    config:
      tags: ["better_be_fresh"]
    freshness:
      warn_after: {count: 12, period: hour}
      error_after: {count: 24, period: hour}
    loaded_at_field: _etl_loaded_at
    database: postgres
    schema: dbt_dougie_fresh
    tables:
      - name: my_model

Then only check that source (but none others) via its tag like this?

dbt source freshness --select tag:better_be_fresh   

@mddataminr
Copy link
Author

mddataminr commented Apr 19, 2023 via email

@jtcohen6
Copy link
Contributor

jtcohen6 commented Apr 19, 2023

@dbeatty10 brilliant example - this actually works if I just defined the tags outside the config dictionary:

version: 2

sources:
  - name: dbt_dougie_fresh
    tags: ["better_be_fresh"]
    freshness:
      warn_after: {count: 12, period: hour}
      error_after: {count: 24, period: hour}
    loaded_at_field: _etl_loaded_at
    database: postgres
    schema: dbt_dougie_fresh
    tables:
      - name: mixtapes
$ dbt source freshness --select tag:better_be_fresh
05:35:50  Running with dbt=1.4.5
...
05:35:51  1 of 1 START freshness of dbt_dougie_fresh.mixtapes ............................ [RUN]

I know that's not totally consistent with how this works for other resource types. As a pleasant surprise, we do actually document that fact (https://docs.getdbt.com/reference/resource-configs/tags#other-resource-types):

Tags can also be applied to sources, exposures, and even specific columns in a resource. These resources do not yet support the config property, so you'll need to specify the tags as a top-level key instead.


We could reformulate this into a separate feature request:

  • Now that sources support that config property (since v1.1), support tags nested under the config dictionary, instead of at the top level, for consistency with other resource types

We've already got some spike work planned over the next few months, to take another good look at the discrepancies between configs and properties, and opportunities for consolidation:

So I'm going to close this issue as resolved for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants