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

TestGenerateCatalogWithExternalNodes #9456

Merged
merged 3 commits into from
Jan 29, 2024
Merged

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Jan 25, 2024

resolves #9458

Problem

catalog from docs generate does not include external nodes, even though that was the case in 1.6. This is because starting from 1.7, the docs generate task started using a ResourceSelector which filters out empty nodes (e.g. external ones) as opposed to iterating over the manifest directly.

Solution

  • Set include_empty_nodes=True in the ResourceTypeSelector for the generate task.
    • This indicates to the selector that 'empty' (e.g. nodes without raw_code, like external nodes) should be included in selection and make their way to the catalog
    • Same approach as was used to select external nodes in the ListCommand, which needed to select external nodes for the result even though they are not 'runnable': https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/task/list.py#L201
  • Add a test that ensures generated catalogs include external nodes when those are available in the project

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

@cla-bot cla-bot bot added the cla:yes label Jan 25, 2024
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6663846) 87.85% compared to head (f601794) 87.91%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9456      +/-   ##
==========================================
+ Coverage   87.85%   87.91%   +0.05%     
==========================================
  Files         160      160              
  Lines       21934    21934              
==========================================
+ Hits        19271    19284      +13     
+ Misses       2663     2650      -13     
Flag Coverage Δ
integration 85.45% <ø> (+0.13%) ⬆️
unit 62.42% <ø> (ø)

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.

Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@graciegoheen
Copy link
Contributor

@MichelleArk What's the reason to backport to 1.1.latest? I think we only need to backport to 1.7.latest?

@MichelleArk
Copy link
Contributor Author

Agreed! Think the 1.1.latest label was just fat-thumbed

@MichelleArk MichelleArk marked this pull request as ready for review January 29, 2024 19:02
@MichelleArk MichelleArk requested a review from a team as a code owner January 29, 2024 19:02
Copy link
Member

@aranke aranke left a comment

Choose a reason for hiding this comment

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

LGTM, would this apply to exposures also?

@MichelleArk
Copy link
Contributor Author

@aranke - good question! Exposures have their own handling for selection: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/graph/selector.py#L168

This should not affect them.

@MichelleArk MichelleArk merged commit 06e55bb into main Jan 29, 2024
52 checks passed
@MichelleArk MichelleArk deleted the test-external-node-in-catalog branch January 29, 2024 19:43
Copy link
Contributor

The backport to 1.7.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.7.latest 1.7.latest
# Navigate to the new working tree
cd .worktrees/backport-1.7.latest
# Create a new branch
git switch --create backport-9456-to-1.7.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 06e55bb93ed771921d656807cd6bfa2dc1995b20
# Push it to GitHub
git push --set-upstream origin backport-9456-to-1.7.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.7.latest

Then, create a pull request where the base branch is 1.7.latest and the compare/head branch is backport-9456-to-1.7.latest.

MichelleArk added a commit that referenced this pull request Jan 29, 2024
@MichelleArk
Copy link
Contributor Author

Manual backport: #9483

MichelleArk added a commit that referenced this pull request Jan 31, 2024
* TestGenerateCatalogWithExternalNodes (#9456)

(cherry picked from commit 06e55bb)

* Flip logic in `packages_for_node` to remove error case

By flipping the logic from `not in` to `in` we can drop the exception
and instead default to the model runtime config when the package isn't
found. We're still trying to grok if there will be any fallout from this.
The tests all pass, but that doesn't guarantee nothing bad will happen.

---------

Co-authored-by: Quigley Malcolm <quigley.malcolm@dbtlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Regression] External nodes not included in catalog during docs generation
3 participants