-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Re-factor list of YAML keys for hooks to late-render #6435
Conversation
Co-authored-by: Kshitij Aranke <kshitij.aranke@dbtlabs.com>
Manually confirmed this fixes the issue. Would be nice to have a test to cover this case to protect against regressions. |
If there aren't existing tests you can piggyback off, happy to help you set up new tests. |
That would be awesome if you could help with the testing part @aranke ! I don't yet know if there are any good existing tests to piggyback from, but the following might help search for candidates: git grep "pre_hook" tests/
git grep "post_hook" tests/
git grep "pre-hook" tests/
git grep "post-hook" tests/ |
Nice work on this @dbeatty10! Much better than just updating the docs :) After a few minutes of quick looking, I wasn't able to find a good test for piggy-backing. There's one test I could find with "macro in a |
I've been struggling to think of a simple platform-independent approach to test that My first thoughts were to add some SQL/DML/etc that modifies the database state, and then we could assert that the intended state is observed. But it's hard to think of a state-changing statement that can be executed in a cross-database manner. As an alternative approach, what if we try specifying an invalid statement and assert that it raises an error? This would confirm that the hook is being executed regardless if it's specified by The project configs for the latter approach might look similar to this: models:
+post-hook:
- "This is an invalid statement and should raise an exception" and models:
+post_hook:
- "This is an invalid statement and should also raise an exception" |
Turns out it doesn't need to be platform-independent -- guessing can just add/extend relevant functional tests here. |
Test that `pre_hook`/`post_hook` are functionally synonymous with `pre-hook`/`post-hook` for model project config
Extended a functional test here and verified that it fails when the bugfix is removed:
|
This reverts commit e83a2be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, maybe we can parameterize these tests, but out of scope for this PR.
resolves #6411
Description
The documentation here appears accurate. But as a user, it's easy for me to miss the subtle difference of a dash and a hyphen and to notice when/where each is relevant.
Is it just possible to treat both
post-hook
andpost_hook
as being synonymous? This pull request hopes the answer is YES!Example
models/my_simple_model.sql
Run it:
😄 Happy:
dbt_project.yml
dbt_project.yml
What this pull request needs
Approach to testing
Rather than being exhaustive with testing all the variations across models, snapshots, and tests, I opted for just extending the basic test case for models. This was to minimize code added to
tests/functional/hooks/test_model_hooks.py
as well as not excessively lengthening the time to run tests. If required, we can revisit this decision.Checklist
changie new
to create a changelog entry