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

Fix source seed selection docs generate #9454

Merged
merged 8 commits into from
Jan 30, 2024

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Jan 25, 2024

resolves #9161

Problem

  1. Sources are not actively participating in resource selection in docs generate. They cannot simply be included as nodes in the ResourceTypeSelector because then the task would attempt to compile a SourceDefinition which leads to all sorts of errors since they are not executable.

  2. Seed selection actually does work, but in the edge case where a seed and source have the same database identifier, and the seed is selected, its catalog metadata is populated under catalog.sources instead of in catalog.nodes. Vice versa happens if the source is selected but the seed is not. If both are selected, both are in the catalog as expected (already tested).

Solution

  1. Use the ResourceTypeSelector with SourceDefinition during catalog generation, after compilation to include queried sources in the catalog result.

  2. Handle edge case by accepting the selected_ids to catalog.make_unique_id_map to only create node and source maps for selected seeds. Update the seed selection test to explicitly test selection for a seed that shares a relation with a source.

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
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.

Copy link

codecov bot commented Jan 25, 2024

Codecov Report

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

Comparison is base (98bbbc1) 87.96% compared to head (2b4b810) 87.94%.

Files Patch % Lines
core/dbt/task/docs/generate.py 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9454      +/-   ##
==========================================
- Coverage   87.96%   87.94%   -0.02%     
==========================================
  Files         166      166              
  Lines       22094    22106      +12     
==========================================
+ Hits        19435    19442       +7     
- Misses       2659     2664       +5     
Flag Coverage Δ
integration 85.43% <96.55%> (-0.02%) ⬇️
unit 62.31% <24.13%> (-0.03%) ⬇️

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.

@MichelleArk MichelleArk force-pushed the fix-source-seed-selection-docs-generate branch from 4861751 to 5634453 Compare January 25, 2024 21:40
@MichelleArk MichelleArk force-pushed the fix-source-seed-selection-docs-generate branch from 6d17b50 to 2b4b810 Compare January 30, 2024 04:08
@MichelleArk MichelleArk marked this pull request as ready for review January 30, 2024 04:10
@MichelleArk MichelleArk requested a review from a team as a code owner January 30, 2024 04:10
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, 1 nit.

)
selected_nodes.extend(source_ids)
selected_node_ids.update(selected_source_ids)
selected_nodes.extend(selected_source_nodes)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Can we use tuple unpacking here?

selected_nodes = (*selected_nodes, *selected_source_nodes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this led to some unsavory mypy issues, so I left it as-is.

@MichelleArk MichelleArk merged commit 719a50c into main Jan 30, 2024
51 checks passed
@MichelleArk MichelleArk deleted the fix-source-seed-selection-docs-generate branch January 30, 2024 21:38
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-9454-to-1.7.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 719a50cc91bc7a2a219b6fa4209e892f14177eb6
# Push it to GitHub
git push --set-upstream origin backport-9454-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-9454-to-1.7.latest.

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.

[CT-3429] [Bug] Selectors don't apply for sources and seeds in dbt docs generate
2 participants