diff --git a/core/dbt/parser/base.py b/core/dbt/parser/base.py index 61e34237e5c..e345a74183c 100644 --- a/core/dbt/parser/base.py +++ b/core/dbt/parser/base.py @@ -109,7 +109,7 @@ def __init__(self, config: RuntimeConfig, manifest: Manifest, component: str) -> self.component = component def __call__(self, parsed_node: Any, override: Optional[str]) -> None: - if parsed_node.package_name in self.package_updaters: + if getattr(parsed_node, "package_name", None) in self.package_updaters: new_value = self.package_updaters[parsed_node.package_name](override, parsed_node) else: new_value = self.default_updater(override, parsed_node) @@ -293,7 +293,7 @@ def update_parsed_node_relation_names( self._update_node_alias(parsed_node, config_dict.get("alias")) # Snapshot nodes use special "target_database" and "target_schema" fields for some reason - if parsed_node.resource_type == NodeType.Snapshot: + if getattr(parsed_node, "resource_type", None) == NodeType.Snapshot: if "target_database" in config_dict and config_dict["target_database"]: parsed_node.database = config_dict["target_database"] if "target_schema" in config_dict and config_dict["target_schema"]: @@ -452,7 +452,7 @@ def _update_node_relation_name(self, node: ManifestNode): # and TestNodes that store_failures. # TestNodes do not get a relation_name without store failures # because no schema is created. - if node.is_relational and not node.is_ephemeral_model: + if getattr(node, "is_relational", None) and not getattr(node, "is_ephemeral_model", None): adapter = get_adapter(self.root_project) relation_cls = adapter.Relation node.relation_name = str(relation_cls.create_from(self.root_project, node)) diff --git a/core/dbt/parser/schema_yaml_readers.py b/core/dbt/parser/schema_yaml_readers.py index 8b1a780a0c6..6ef1884d494 100644 --- a/core/dbt/parser/schema_yaml_readers.py +++ b/core/dbt/parser/schema_yaml_readers.py @@ -764,6 +764,9 @@ def parse_saved_query(self, unparsed: UnparsedSavedQuery) -> None: group=config.group, ) + for export in parsed.exports: + self.schema_parser.update_parsed_node_relation_names(export, export.config.to_dict()) # type: ignore + # Only add thes saved query if it's enabled, otherwise we track it with other diabled nodes if parsed.config.enabled: self.manifest.add_saved_query(self.yaml.file, parsed)