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

Feature: Support cross-project Group evaluation #60

Merged
merged 6 commits into from
Jun 1, 2024

Conversation

nicholasyager
Copy link
Owner

@nicholasyager nicholasyager commented May 13, 2024

Description and Motivation

Within dbt-core, it is possible to assign models and other resources to groups. These groups can be used to restrict other downstream resources from ref-ing the resource if they are not part of the same group. Due to the way that dbt-core instantiates ModelNodes based on ModelNodeArgs, it has not been possible to enforce group reference constraints across project boundaries, and ref-ing protected nodes from across projects has historically yielded error messages lacking the group name of the upstream node (#59).

This pull request unblocks cross-project group evaluation by extending our internal LoomModelNodeArgs construct to include a group string, and wraps the existing ModelNode.from_args() classmethod with an internal model_node_wrapper, which inject the upstream node's group string into the resulting ModelNode. I also added a similar wrapper to ensure that downstream projects have their upstream-projects injected as valid group names during group validity checks. The metadata will NOT be passed into the downstream manifest, but this is a good first step.

Along the way, I found another defect in dbt-core's evaluation of access evaluation for private models, which prevents grouped private models in projects with restricted access from using generic tests (dbt-labs/dbt-core#10134). This means that we cannot enforce checks against protected models as described in #43. I'll restore this functionality once the underlying defect has been resolved in dbt-core.

The `groups` property is explicitly excluded from ModelNodeArgs being
added into ModelNodes in dbt-core's current implementation of `from_args`.
To work around this gap/limitation, I've implemented a nice little
wrapper function that injects the `group` name into the ModelNode
after the model is created. This opens the door to a few other fun
things, too ;-)
@nicholasyager nicholasyager added bug Something isn't working enhancement New feature or request labels May 13, 2024
@nicholasyager nicholasyager self-assigned this May 13, 2024
@nicholasyager
Copy link
Owner Author

@z3z1ma, can you please give this branch a test to confirm if it has the intended outcome? Thanks!

@nicholasyager nicholasyager merged commit 5f6681d into main Jun 1, 2024
3 checks passed
@z3z1ma
Copy link

z3z1ma commented Jun 1, 2024

Sorry for not getting back to you here. Thanks for the fix 💯 much appreciated sir!

@nicholasyager nicholasyager deleted the fix/inject_groups_into_modelnodes branch July 11, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants