-
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
ADAP-850: Support test results as a view #8653
Conversation
…ategy parameter in test materialization
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8653 +/- ##
==========================================
- Coverage 86.56% 86.51% -0.05%
==========================================
Files 176 176
Lines 25820 25869 +49
==========================================
+ Hits 22350 22381 +31
- Misses 3470 3488 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
tests/adapter/dbt/tests/adapter/store_test_failures_tests/test_persist_results.py
Outdated
Show resolved
Hide resolved
…, update test to check for relation type and confirm views update
@mikealfare Did you add any test cases that cover the generic tests described in the reprex of "3. Generic tests" here? |
I'm working on that today. I wanted to swap the existing state first and get that pushed up. |
…terialized-tests/adap-850
@colin-rogers-dbt identified an unspecified piece here:
UX to address this: #6914 (comment) |
Generic test test cases are in and passing. I merged your updates @dbeatty10 and they addressed this gap.
This is possible, but not intuitive. I added a test case that demonstrates how to do this. Basically you set dbt-core/tests/adapter/dbt/tests/adapter/store_test_failures_tests/_files.py Lines 96 to 101 in c09b81d
It's run in this line:
|
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, doesn't look like we have covered these with unit tests in the past but worth considering if this change justifies some: https://github.com/dbt-labs/dbt-core/blob/main/tests/unit/test_model_config.py
|
||
The intention of this block is to behave as if `store_failures_as` is the only setting, | ||
but still allow for backwards compatibility for `store_failures`. | ||
See https://github.com/dbt-labs/dbt-core/issues/6914 for more information. |
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.
🥇
@mikealfare Thanks for explaining how this is possible right now, even it if it isn't intuitive. We would love to make this intuitive so that it's easier to document and easier to accomplish. Do you have any concerns with the proposal in #6914 (comment)? It proposes using |
@dbeatty10 in terms of the config parameter naming are you comfortable with proceeding with I prefer |
@dbeatty10, I'm comfortable moving forward with "ephemeral"; I'll make those changes and push it up. I agree with @colin-rogers-dbt that we should stick with And to confirm, is this all that's left for this PR? Or am I missing another issue? |
@colin-rogers-dbt and @mikealfare My order of preference
This order is meant to capture what would be most easy for users. I totally understand that there may be engineering considerations that could affect one or more of these. If so, would love to learn anything you've uncovered or anything you think should be taken into consideration. To be clear, I think any of them are workable long-term from a user perspective. They are just ordered from most intuitive to least. Theoretically, an experienced dbt user wouldn't even need to consult the documentation for the first one, but would definitely need to read docs for the last one. |
Outstanding things to solveFrom my perspective, here's the user experience items that we should finalize:
See above for my take on the first two, and see below for the last one. How to behave if the user supplies a non-accepted valueIt seems like we should raise an error for invalid values. It could be something similar to this:
What do you think about raising an error when the config includes an invalid value? |
As @mikealfare described above
I like this principle a lot but are we concerned about reusing words in different contexts that accept different inputs and mean different things? In this case Also, I don't think we do but any chance we're going to want to store success in the future? (i.e. would we need separate 'strategies' for successful /failing tests?)
+1 a compilation error is what a user should expect here |
If we could go back and change how tests work, then I agree that
Given this is the next preference, I'll start making these updates. But I do have some questions:
Regarding the second question, I could see the list getting shorter or longer across resource type (e.g. @colin-rogers-dbt got this in while I was writing this up. So to include his piece here, he is highlighting exactly my concern with
From the above, it seems like this is
The valid values are currently any value of
I'm sure we don't fail gracefully here as the valid value list is implicit. I'll see if I can throw something in along the lines of your suggestion, but I can't promise that it will cover all cases. |
…ff store_failures at the model level
For those following along at home, ephemeral is now in, as well as the compilation error. |
Definitely hear you both that using I'm not attached to the name By "resource types" (AKA "node types"), I mean these which are listed in the code here.
|
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.
Works as expected
I re-tried the use cases described here in a local environment and they worked 😎
Each of these values all behaved as expected:
store_failures_as: ephemeral
store_failures_as: null
store_failures_as:
I also tried giving invalid values like the following, which also gave appropriate error messages:
store_failures_as: materialized_view
store_failures_as: carrot
store_failures_as: none
store_failures_as: None
One edge case
One discovered edge case was switching from table
(or view
) to ephemeral
between successive dbt run
s.
When switching from table
to view
, the 1st relation in dropped and the 2nd is created. But when switching from table
to ephemeral
, the table persists afterwards and needs to be manually dropped.
Summary
Regardless of that edge case, approving this PR 👍
We can follow-up in a separate issue to decide what to do when switching from table
(or view
) to ephemeral
.
Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#4246 |
resolves #6914
docs: dbt-labs/docs.getdbt.com#4246
Problem
We now support materialized views (and dynamic tables in Snowflake). These new objects can update without running dbt. However, the test results will stay static if we run them with
--store-failures
, or just won't exist at all if we don't specify--store-failures
. This is philosophically inconsistent behavior.Solution
Support test results as a view, so that they will always show the current failures without the need to run dbt. We should also support table as a relation type since this is effectively
--store-failures
. Users can specify this setting in the config block in their tests by settingstore_failures_as="view"
.Approach:
TestConfig
calledstore_failures_as
(wasstrategy
in previous iterations)store_failures_as
to"table"
to align with existing behavior for whenstore_failures = True
store_failures_as
in thetest
materialization'table'
with the contents ofstore_failures_as
store_failures_as
with a non-empty default ("table"
)store_failures
tests still pass as-isChecklist