Skip to content

Commit

Permalink
Check resource_type before DbtReferenceError
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed Jun 9, 2023
1 parent 21e08d8 commit 108a0a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/dbt/context/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ def resolve(
elif (
target_model.resource_type == NodeType.Model
and target_model.access == AccessType.Private
# don't raise this reference error for ad hoc 'preview' queries
and self.model.resource_type != NodeType.SqlOperation
and self.model.resource_type != NodeType.RPCCall # TODO: rm
):
if not self.model.group or self.model.group != target_model.group:
raise DbtReferenceError(
Expand Down
9 changes: 7 additions & 2 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,8 +1683,13 @@ def _process_refs_for_node(manifest: Manifest, current_project: str, node: Manif
)
continue

# Handle references to models that are private
elif isinstance(target_model, ModelNode) and target_model.access == AccessType.Private:
# Handle references to models that are private, unless this is an 'ad hoc' query (SqlOperation, RPCCall)
elif (
isinstance(target_model, ModelNode)
and target_model.access == AccessType.Private
and node.resource_type != NodeType.SqlOperation
and node.resource_type != NodeType.RPCCall # TODO: rm
):
if not node.group or node.group != target_model.group:
raise dbt.exceptions.DbtReferenceError(
unique_id=node.unique_id,
Expand Down

0 comments on commit 108a0a7

Please sign in to comment.