-
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
[CT-3123] Make seed inputs optional for unit tests #8652
Comments
Maybe it "just works"?Let's suppose unit-tests:
- name: test_my_model
model: my_model
given:
- input: ref('my_upstream_model_a')
format: csv
fixture: my_upstream_model_a_fixture Then we can imagine that the above should "just work" even if Can we think of reasons why it wouldn't "just work"? An additional thoughtFor the special case of unit-tests:
- name: test_my_model
model: my_model
given:
- input: ref('my_upstream_model_a') Or maybe even going the whole way and making the unit-tests:
- name: test_my_model
model: my_model
given:
# presumably other `input`s are explicitly defined here, but at least `my_upstream_model_a` is implicitly defined -- since it's a seed, we already have all the data we need to mock it |
Updated the issue!! Thanks @dbeatty10 for your great ideas :) Additional thought... What would happen if you didn't care to supply mock data for one of the direct parent models (because it's not relevant for the logic that you're trying to test), where you want to instead use an "empty" mock data set or a one-row, all NULL data set?
The second feels less magical, but I like that it's an intentional decision rather than the risk of "oops, I forgot to add mock data for Food for thought... probably for a separate issue. cc: @MichelleArk |
Notes from refinement:
|
Notes from estimation:
|
Hey @graciegoheen, can you please clarify how this scenario can be reached during unit testing?
From what I can see, these only get triggered during Furthermore, the spec labels this as an anti-goal:
Given this, is it fair to cut pre- / post-hooks for seeds out of scope? |
Yes, unit testing seeds directly is an anti-goal - so we can cut pre- / post- hooks for seeds out of scope! |
* Initial implementation of unit testing (from pr #2911) Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com> * 8295 unit testing artifacts (#8477) * unit test config: tags & meta (#8565) * Add additional functional test for unit testing selection, artifacts, etc (#8639) * Enable inline csv format in unit testing (#8743) * Support unit testing incremental models (#8891) * update unit test key: unit -> unit-tests (#8988) * convert to use unit test name at top level key (#8966) * csv file fixtures (#9044) * Unit test support for `state:modified` and `--defer` (#9032) Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com> * Allow use of sources as unit testing inputs (#9059) * Use daff for diff formatting in unit testing (#8984) * Fix #8652: Use seed file from disk for unit testing if rows not specified in YAML config (#9064) Co-authored-by: Michelle Ark <MichelleArk@users.noreply.github.com> Fix #8652: Use seed value if rows not specified * Move unit testing to test and build commands (#9108) * Enable unit testing in non-root packages (#9184) * convert test to data_test (#9201) * Make fixtures files full-fledged members of manifest and enable partial parsing (#9225) * In build command run unit tests before models (#9273) --------- Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com> Co-authored-by: Michelle Ark <MichelleArk@users.noreply.github.com> Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com> Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com> Co-authored-by: Kshitij Aranke <kshitij.aranke@dbtlabs.com>
Description
Our proposed unit testing spec, doesn't yet take into account if one of the inputs to the model you want to add a unit test to is a
seed
.Current behavior: Let's say
model_a
depends onmy_seed
. If you want to add a unit test tomodel_a
- you need to define an input formy_seed
. That feels redundant since seeds don't often change and are already small data inputs.Proposed solution:
Let's say you're unit testing
my_favorite_model
that depends on:my_favorite_source
(a source)my_second_favorite_model
(a model)my_special_seed
(a seed)You must supply mock input data for all of the direct parent models and sources.
In this case, we just use your seed for
my_special_seed
input.You may supply mock input data for direct parent seeds, if desired.
In this case, we use your fixture
my_special_seed_fixture
formy_special_seed
input.Acceptance Criteria
Impact to other teams
None
Will backports be required?
No
Context
The text was updated successfully, but these errors were encountered: