-
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
Rename tests: singular + generic #3880
Conversation
d57c8f4
to
290093d
Compare
290093d
to
2a9fdfb
Compare
@@ -325,8 +325,6 @@ def _parse_generic_test( | |||
'kwargs': builder.args, | |||
} | |||
tags = sorted(set(itertools.chain(tags, builder.tags()))) | |||
if 'schema' not in tags: |
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.
This seems randomly removed but maybe it isn't?
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.
Super fair question!
In v0.18, we introduced a selection method, test_type:
, that allowed users to select just schema tests (dbt test --models test_type:schema
) or data tests (dbt test --models test_type:data
).
Prior to that, we supported the same functionality, but in a pretty silly way. dbt would secretly add tags—'schema'
to schema tests, 'data'
to data tests—and then users could pass a flag dbt test --schema
to select all tests tagged "schema," or dbt test --data
to select all tests tagged "data." Funny enough, that would include schema tests manually tagged "data," too, or data tests that selected from models tagged "schema." Not a good system. We haven't explicitly said that the older system will stop working in a future version, but we effectively replaced it with the test_type
method in the documentation (e.g. the changelog note here).
This PR takes the opinionated view that we should do away with that legacy approach to the functionality, since we've had a better approach (test_type
selector) for several versions now. To that end, there's some backwards compatibility for the newer approach, and total deprecation fro the older approach:
- Stop secretly adding
'schema'
and'data'
tags to tests - Deprecate
--schema
and--data
flags entirely - Continue supporting
test_type:schema
+test_type:data
as aliases fortest_type:generic
andtest_type:singular
, respectively
@@ -269,11 +269,6 @@ def parse_source_test( | |||
tags=tags, | |||
column_name=column_name | |||
) | |||
# we can't go through result.add_node - no file... instead! | |||
if node.config.enabled: |
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.
Same here. What does this have to do with the rename? Honestly asking to learn
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.
This is the fix for #3347, in which we noticed a while ago that source tests are added to the manifest twice.
Things I don't know:
- why that doesn't cause a functional error currently
- why that started causing a functional error when I made the other changes in this PR, i.e. renamed things
Despite not knowing those things, I feel reasonably good about making this fix. I can move the commit (0adec32) into a separate PR if that would make things clearer.
2a9fdfb
to
76f3426
Compare
76f3426
to
c9e3a7c
Compare
4aac13f
to
8e66df3
Compare
8e66df3
to
7ff2f27
Compare
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.
Looks good!
Updated syntax from legacy test_type name (data) to current nomenclature (singular) ## Description & motivation <!--- Describe your changes, and why you're making them. Is this linked to an open issue, a pull request on dbt core, etc? To learn more about the writing conventions used in the dbt Labs docs, see the [Content style guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md). --> I was confused by the test_type:data designation under Test Selection: Examples. I was able to find a pull request documenting the legacy test_type tags [here](dbt-labs/dbt-core#3880). I used this to update the example for the current version. Co-authored-by: mirnawong1 <[email protected]> Co-authored-by: Leona B. Campbell <[email protected]>
resolves #3234, #3259, #3347
Basics
data
→singular
,schema
→generic
test_type:schema
+test_type:data
Opinionated choices
schema_test
/data_test
). Singular test FQNs are constructed exactly the same as models, by relative path (excluding top-level project folder) and name. Generic test FQNs include relative path to the yaml file that defines them.compiled_path
will also no longer include the test type prefix (schema_test/
,data_test/
). I removed this because it seems irrelevant, and has no real functional effect.--data
and--schema
flags todbt test
entirely. Removedata
+schema
tags from tests. This will be a breaking change for users who are still relying on the old way of doing this, before we released thetest_type:
selection method in v0.18. I put this into a separate commit, so we can revert if we don't agree.Comments
Since I'm already touching test FQNs, why not make them even better? (Improve test FQNs #3259, probably out of scope here, though sort of a shame to leave them as they are in v1.0)I took a swing at these. Will add some comments above.schema_test
ordata_test
when they are dbt-core modules. I'd prefer to not rename integration tests for now, to avoid big git diffs.Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.