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

Feature/source freshness hooks #9366

Merged
merged 7 commits into from
Jan 23, 2024
Merged

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Jan 12, 2024

resolves #5609

Problem

Currently, on-run-* hooks are not supported in the dbt source freshness command, this PR makes it so it does.

Solution

Changed the FreshnessTask class to inherit from RunTask (as all other task types that support hooks do).

Alternative solutions:

  • Move the hook logic to GraphRunnableTask and disabling in CompileTask - feels a little messier (disabling parent functionality in inheriter).
  • Create a HookTask in the middle of the inheritance tree - seems like a lot more work when every other hook-able task just inherits from RunTask.

Additionally, this change has been made backwards-compatible with previous versions of dbt which did not include project hooks by default for dbt source freshness commands via a project flag + tests added across the different scenarios (default configuration, flag explicitly disabled, flag explicitly enabled)

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label Jan 12, 2024
Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c547aac) 86.98% compared to head (002c3c4) 87.03%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9366      +/-   ##
==========================================
+ Coverage   86.98%   87.03%   +0.04%     
==========================================
  Files         187      187              
  Lines       24971    25026      +55     
==========================================
+ Hits        21722    21782      +60     
+ Misses       3249     3244       -5     
Flag Coverage Δ
integration 84.48% <100.00%> (+0.11%) ⬆️
unit 63.33% <76.47%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichelleArk MichelleArk marked this pull request as ready for review January 12, 2024 21:53
@MichelleArk MichelleArk requested a review from a team as a code owner January 12, 2024 21:53
@MichelleArk MichelleArk requested a review from aranke January 12, 2024 21:53
@MichelleArk MichelleArk requested a review from gshank January 12, 2024 21:54
@MichelleArk
Copy link
Contributor Author

Initial review covering first 2 commits of this change: #9322 (comment)

Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine. As things for possible future improvements, that whole flags processing thing is getting complicated. We should look for an opportunity to refactor it. Also mixing in different Status enums is something that's not wonderful. We need to do a rethink of all of those status codes sometime. It might be better to have a single enum instead of all of these different ones.

@MichelleArk
Copy link
Contributor Author

As things for possible future improvements, that whole flags processing thing is getting complicated. We should look for an opportunity to refactor it.

Yeah, I agree. It's definitely got a lot of responsibilities and is quite aware of dbt-specific CLI flags even though it's meant to be more generalized. In the meantime, I've added an additional unit test for the project-only flag behaviour so it'll be safer to refactor in the future.

Also mixing in different Status enums is something that's not wonderful. We need to do a rethink of all of those status codes sometime. It might be better to have a single enum instead of all of these different ones.

We may be able to take a stab at this with some of the ongoing dbt/artifacts refactoring, but agree it shouldn't block this work.

@MichelleArk MichelleArk added the user docs [docs.getdbt.com] Needs better documentation label Jan 23, 2024
@MichelleArk MichelleArk merged commit dc59c70 into main Jan 23, 2024
56 checks passed
@FishtownBuildBot
Copy link
Collaborator

Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#4787

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-985] [Feature] on-run-end hook and results variable support for source freshness command
4 participants