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

Make fixtures files full-fledged members of manifest and enable partial parsing #9225

Merged
merged 17 commits into from
Dec 7, 2023

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Dec 6, 2023

resolves #9067

Problem

Because fixture files were not full-fledged SourceFiles and didn't have a representation in the manifest, we couldn't do partial parsing for fixture file changes.

Solution

Create a new source file class, FixtureSourceFile, and a lightweight UnitTestFixture node-like object in the manifest fixtures dictionary. Store the unique_ids of the fixtures and the related unit_tests in the source_file and process them in partial parsing.

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

@gshank gshank requested a review from a team as a code owner December 6, 2023 01:08
@gshank gshank requested a review from emmyoop December 6, 2023 01:08
@cla-bot cla-bot bot added the cla:yes label Dec 6, 2023
Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (ca82f54) 86.89% compared to head (2117880) 86.90%.
Report is 1 commits behind head on unit_testing_feature_branch.

Files Patch % Lines
core/dbt/contracts/files.py 81.81% 2 Missing ⚠️
core/dbt/contracts/graph/manifest.py 81.81% 2 Missing ⚠️
core/dbt/parser/fixtures.py 96.55% 1 Missing ⚠️
core/dbt/parser/partial.py 95.23% 1 Missing ⚠️
core/dbt/parser/unit_tests.py 97.50% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           unit_testing_feature_branch    #9225      +/-   ##
===============================================================
+ Coverage                        86.89%   86.90%   +0.01%     
===============================================================
  Files                              180      181       +1     
  Lines                            27127    27236     +109     
===============================================================
+ Hits                             23572    23670      +98     
- Misses                            3555     3566      +11     
Flag Coverage Δ
integration 83.90% <95.00%> (+0.01%) ⬆️
unit 64.81% <49.28%> (-0.04%) ⬇️

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.

@@ -727,21 +727,21 @@ def search(self, included_nodes: Set[UniqueId], selector: str) -> Iterator[Uniqu

manifest: WritableManifest = self.previous_state.manifest

for node, real_node in self.all_nodes(included_nodes):
for unique_id, node in self.all_nodes(included_nodes):
Copy link
Contributor

Choose a reason for hiding this comment

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

thank you for renaming this here -- this has been bugging me forever!

@MichelleArk
Copy link
Contributor

This TODO in test_statecan also be cleaned up as part of this work! It should test the appropriate tests are selected when a file fixture is updated.

Copy link
Contributor

@MichelleArk MichelleArk left a comment

Choose a reason for hiding this comment

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

Looking great! No blocking concerns :)

Copy link
Member

@emmyoop emmyoop left a comment

Choose a reason for hiding this comment

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

Looks good, just one small suggestion.

@@ -321,6 +316,58 @@ def _build_fqn(self, package_name, original_file_path, model_name, test_name):
fqn.append(test_name)
return fqn

def _get_fixture(self, fixture_name: str, project_name: str):
fixture_unique_id = f"fixture.{project_name}.{fixture_name}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fixture_unique_id = f"fixture.{project_name}.{fixture_name}"
fixture_unique_id = f"{NodeType.Fixture}.{project_name}.{fixture_name}"

@gshank gshank merged commit 9a79fba into unit_testing_feature_branch Dec 7, 2023
49 checks passed
@gshank gshank deleted the 9067-fixture_files branch December 7, 2023 15:53
gshank added a commit that referenced this pull request Jan 16, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants