diff --git a/.changes/unreleased/Under the Hood-20240126-164038.yaml b/.changes/unreleased/Under the Hood-20240126-164038.yaml new file mode 100644 index 00000000000..6d542ada4f7 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20240126-164038.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Move `SavedQuery` data definition to `dbt/artifacts` +time: 2024-01-26T16:40:38.790993-08:00 +custom: + Author: QMalcolm + Issue: "9386" diff --git a/core/dbt/artifacts/resources/__init__.py b/core/dbt/artifacts/resources/__init__.py index 2b94afe3681..6efff207390 100644 --- a/core/dbt/artifacts/resources/__init__.py +++ b/core/dbt/artifacts/resources/__init__.py @@ -1,8 +1,23 @@ -from dbt.artifacts.resources.base import BaseResource +from dbt.artifacts.resources.base import BaseResource, GraphResource # alias to latest resource definitions +from dbt.artifacts.resources.v1.components import DependsOn, NodeVersion, RefArgs from dbt.artifacts.resources.v1.documentation import Documentation from dbt.artifacts.resources.v1.macro import Macro, MacroDependsOn, MacroArgument from dbt.artifacts.resources.v1.docs import Docs from dbt.artifacts.resources.v1.group import Group from dbt.artifacts.resources.v1.owner import Owner +from dbt.artifacts.resources.v1.saved_query import ( + Export, + ExportConfig, + QueryParams, + SavedQuery, + SavedQueryConfig, + SavedQueryMandatory, +) +from dbt.artifacts.resources.v1.semantic_layer_components import ( + FileSlice, + SourceFileMetadata, + WhereFilter, + WhereFilterIntersection, +) diff --git a/core/dbt/artifacts/resources/base.py b/core/dbt/artifacts/resources/base.py index f82f072bbcf..0c29c1d1613 100644 --- a/core/dbt/artifacts/resources/base.py +++ b/core/dbt/artifacts/resources/base.py @@ -1,6 +1,7 @@ from dataclasses import dataclass from dbt_common.dataclass_schema import dbtClassMixin from dbt_common.contracts.util import Replaceable +from typing import List from dbt.artifacts.resources.types import NodeType @@ -13,3 +14,8 @@ class BaseResource(dbtClassMixin, Replaceable): path: str original_file_path: str unique_id: str + + +@dataclass +class GraphResource(BaseResource): + fqn: List[str] diff --git a/core/dbt/artifacts/resources/v1/components.py b/core/dbt/artifacts/resources/v1/components.py new file mode 100644 index 00000000000..9f3e0c8a967 --- /dev/null +++ b/core/dbt/artifacts/resources/v1/components.py @@ -0,0 +1,37 @@ +from dataclasses import dataclass, field +from dbt.artifacts.resources.v1.macro import MacroDependsOn +from dbt_common.dataclass_schema import dbtClassMixin +from typing import Dict, List, Optional, Union + + +NodeVersion = Union[str, float] + + +@dataclass +class DependsOn(MacroDependsOn): + nodes: List[str] = field(default_factory=list) + + def add_node(self, value: str): + if value not in self.nodes: + self.nodes.append(value) + + +@dataclass +class RefArgs(dbtClassMixin): + name: str + package: Optional[str] = None + version: Optional[NodeVersion] = None + + @property + def positional_args(self) -> List[str]: + if self.package: + return [self.package, self.name] + else: + return [self.name] + + @property + def keyword_args(self) -> Dict[str, Optional[NodeVersion]]: + if self.version: + return {"version": self.version} + else: + return {} diff --git a/core/dbt/artifacts/resources/v1/saved_query.py b/core/dbt/artifacts/resources/v1/saved_query.py new file mode 100644 index 00000000000..8fd336eb6a5 --- /dev/null +++ b/core/dbt/artifacts/resources/v1/saved_query.py @@ -0,0 +1,90 @@ +from __future__ import annotations +import time + +from dataclasses import dataclass, field +from dbt.artifacts.resources.base import GraphResource +from dbt.artifacts.resources.v1.components import DependsOn, RefArgs +from dbt.artifacts.resources.v1.semantic_layer_components import ( + SourceFileMetadata, + WhereFilterIntersection, +) +from dbt_common.contracts.config.base import BaseConfig, CompareBehavior, MergeBehavior +from dbt_common.dataclass_schema import dbtClassMixin +from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType +from typing import Any, Dict, List, Optional + + +@dataclass +class ExportConfig(dbtClassMixin): + """Nested configuration attributes for exports.""" + + export_as: ExportDestinationType + schema_name: Optional[str] = None + alias: Optional[str] = None + + +@dataclass +class Export(dbtClassMixin): + """Configuration for writing query results to a table.""" + + name: str + config: ExportConfig + + +@dataclass +class QueryParams(dbtClassMixin): + """The query parameters for the saved query""" + + metrics: List[str] + group_by: List[str] + where: Optional[WhereFilterIntersection] + + +@dataclass +class SavedQueryConfig(BaseConfig): + """Where config options for SavedQueries are stored. + + This class is much like many other node config classes. It's likely that + this class will expand in the direction of what's in the `NodeAndTestConfig` + class. It might make sense to clean the various *Config classes into one at + some point. + """ + + enabled: bool = True + group: Optional[str] = field( + default=None, + metadata=CompareBehavior.Exclude.meta(), + ) + meta: Dict[str, Any] = field( + default_factory=dict, + metadata=MergeBehavior.Update.meta(), + ) + export_as: Optional[ExportDestinationType] = None + schema: Optional[str] = None + + +@dataclass +class SavedQueryMandatory(GraphResource): + query_params: QueryParams + exports: List[Export] + + +@dataclass +class SavedQuery(SavedQueryMandatory): + description: Optional[str] = None + label: Optional[str] = None + metadata: Optional[SourceFileMetadata] = None + config: SavedQueryConfig = field(default_factory=SavedQueryConfig) + unrendered_config: Dict[str, Any] = field(default_factory=dict) + group: Optional[str] = None + depends_on: DependsOn = field(default_factory=DependsOn) + created_at: float = field(default_factory=lambda: time.time()) + refs: List[RefArgs] = field(default_factory=list) + + @property + def metrics(self) -> List[str]: + return self.query_params.metrics + + @property + def depends_on_nodes(self): + return self.depends_on.nodes diff --git a/core/dbt/contracts/graph/semantic_layer_common.py b/core/dbt/artifacts/resources/v1/semantic_layer_components.py similarity index 58% rename from core/dbt/contracts/graph/semantic_layer_common.py rename to core/dbt/artifacts/resources/v1/semantic_layer_components.py index a7535bd35de..540317d0889 100644 --- a/core/dbt/contracts/graph/semantic_layer_common.py +++ b/core/dbt/artifacts/resources/v1/semantic_layer_components.py @@ -21,3 +21,27 @@ class WhereFilterIntersection(dbtClassMixin): @property def filter_expression_parameter_sets(self) -> Sequence[Tuple[str, FilterCallParameterSets]]: raise NotImplementedError + + +@dataclass +class FileSlice(dbtClassMixin): + """Provides file slice level context about what something was created from. + + Implementation of the dbt-semantic-interfaces `FileSlice` protocol + """ + + filename: str + content: str + start_line_number: int + end_line_number: int + + +@dataclass +class SourceFileMetadata(dbtClassMixin): + """Provides file context about what something was created from. + + Implementation of the dbt-semantic-interfaces `Metadata` protocol + """ + + repo_file_path: str + file_slice: FileSlice diff --git a/core/dbt/context/providers.py b/core/dbt/context/providers.py index fbb64da5553..e8aba9355e2 100644 --- a/core/dbt/context/providers.py +++ b/core/dbt/context/providers.py @@ -16,6 +16,7 @@ from typing_extensions import Protocol from dbt.adapters.base.column import Column +from dbt.artifacts.resources import NodeVersion, RefArgs from dbt_common.clients.jinja import MacroProtocol from dbt.adapters.factory import get_adapter, get_adapter_package_names, get_adapter_type_names from dbt_common.clients import agate_helper @@ -38,13 +39,11 @@ SourceDefinition, Resource, ManifestNode, - RefArgs, AccessType, SemanticModel, UnitTestNode, ) from dbt.contracts.graph.metrics import MetricReference, ResolvedMetricReference -from dbt.contracts.graph.unparsed import NodeVersion from dbt_common.events.functions import get_metadata_vars from dbt_common.exceptions import ( DbtInternalError, diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 4b7ed18258b..4a896c5b612 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -43,9 +43,10 @@ UnitTestDefinition, UnitTestFileFixture, ) -from dbt.contracts.graph.unparsed import SourcePatch, NodeVersion, UnparsedVersion +from dbt.contracts.graph.unparsed import SourcePatch, UnparsedVersion # to preserve import paths +from dbt.artifacts.resources import NodeVersion from dbt.artifacts.schemas.manifest import WritableManifest, ManifestMetadata, UniqueID from dbt.contracts.files import ( SourceFile, diff --git a/core/dbt/contracts/graph/model_config.py b/core/dbt/contracts/graph/model_config.py index 1dbb0a22fd7..6f42f56a31f 100644 --- a/core/dbt/contracts/graph/model_config.py +++ b/core/dbt/contracts/graph/model_config.py @@ -2,6 +2,7 @@ from typing import Any, List, Optional, Dict, Union, Type from typing_extensions import Annotated +from dbt.artifacts.resources import SavedQueryConfig from dbt_common.contracts.config.base import BaseConfig, MergeBehavior, CompareBehavior from dbt_common.contracts.config.materialization import OnConfigurationChangeOption from dbt_common.contracts.config.metadata import Metadata, ShowBehavior @@ -14,7 +15,6 @@ from dbt.contracts.util import Replaceable, list_str from dbt import hooks from dbt.node_types import NodeType, AccessType -from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType from mashumaro.jsonschema.annotations import Pattern @@ -62,29 +62,6 @@ class SemanticModelConfig(BaseConfig): ) -@dataclass -class SavedQueryConfig(BaseConfig): - """Where config options for SavedQueries are stored. - - This class is much like many other node config classes. It's likely that - this class will expand in the direction of what's in the `NodeAndTestConfig` - class. It might make sense to clean the various *Config classes into one at - some point. - """ - - enabled: bool = True - group: Optional[str] = field( - default=None, - metadata=CompareBehavior.Exclude.meta(), - ) - meta: Dict[str, Any] = field( - default_factory=dict, - metadata=MergeBehavior.Update.meta(), - ) - export_as: Optional[ExportDestinationType] = None - schema: Optional[str] = None - - @dataclass class MetricConfig(BaseConfig): enabled: bool = True diff --git a/core/dbt/contracts/graph/node_args.py b/core/dbt/contracts/graph/node_args.py index 18b286b2ecc..cd19252275c 100644 --- a/core/dbt/contracts/graph/node_args.py +++ b/core/dbt/contracts/graph/node_args.py @@ -2,7 +2,7 @@ from datetime import datetime from typing import Optional, List -from dbt.contracts.graph.unparsed import NodeVersion +from dbt.artifacts.resources import NodeVersion from dbt.node_types import NodeType, AccessType diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 666affe38ed..c63f71f6ba3 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -17,13 +17,11 @@ from dbt_common.clients.system import write_file from dbt.contracts.files import FileHash -from dbt.contracts.graph.saved_queries import Export, QueryParams from dbt.contracts.graph.semantic_models import ( Defaults, Dimension, Entity, Measure, - SourceFileMetadata, ) from dbt.contracts.graph.unparsed import ( ConstantPropertyInput, @@ -35,7 +33,6 @@ Owner, Quoting, TestDef, - NodeVersion, UnparsedSourceDefinition, UnparsedSourceTableDefinition, UnparsedColumn, @@ -44,7 +41,6 @@ UnitTestOutputFixture, ) from dbt.contracts.graph.node_args import ModelNodeArgs -from dbt.contracts.graph.semantic_layer_common import WhereFilterIntersection from dbt.contracts.util import Replaceable from dbt_common.contracts.config.properties import AdditionalPropertiesMixin from dbt_common.events.functions import warn_or_error @@ -91,17 +87,23 @@ SemanticModelConfig, UnitTestConfig, UnitTestNodeConfig, - SavedQueryConfig, ) from dbt.artifacts.resources import ( BaseResource, + DependsOn, Docs, MacroDependsOn, MacroArgument, Documentation as DocumentationResource, Macro as MacroResource, + NodeVersion, Group as GroupResource, + GraphResource, + RefArgs as RefArgsResource, + SavedQuery as SavedQueryResource, + SourceFileMetadata as SourceFileMetadataResource, + WhereFilterIntersection as WhereFilterIntersectionResource, ) @@ -170,36 +172,13 @@ def get_materialization(self): @dataclass -class GraphNode(BaseNode): +class GraphNode(GraphResource, BaseNode): """Nodes in the DAG. Macro and Documentation don't have fqn.""" - fqn: List[str] - def same_fqn(self, other) -> bool: return self.fqn == other.fqn -@dataclass -class RefArgs(dbtClassMixin): - name: str - package: Optional[str] = None - version: Optional[NodeVersion] = None - - @property - def positional_args(self) -> List[str]: - if self.package: - return [self.package, self.name] - else: - return [self.name] - - @property - def keyword_args(self) -> Dict[str, Optional[NodeVersion]]: - if self.version: - return {"version": self.version} - else: - return {} - - @dataclass class ColumnInfo(AdditionalPropertiesMixin, ExtensibleDbtClassMixin, Replaceable): """Used in all ManifestNodes and SourceDefinition""" @@ -255,15 +234,6 @@ def identifier(self): return self.alias -@dataclass -class DependsOn(MacroDependsOn): - nodes: List[str] = field(default_factory=list) - - def add_node(self, value: str): - if value not in self.nodes: - self.nodes.append(value) - - @dataclass class ParsedNodeMandatory(GraphNode, HasRelationMetadata, Replaceable): alias: str @@ -479,7 +449,7 @@ class CompiledNode(ParsedNode): so all ManifestNodes except SeedNode.""" language: str = "sql" - refs: List[RefArgs] = field(default_factory=list) + refs: List[RefArgsResource] = field(default_factory=list) sources: List[List[str]] = field(default_factory=list) metrics: List[List[str]] = field(default_factory=list) depends_on: DependsOn = field(default_factory=DependsOn) @@ -1420,7 +1390,7 @@ class Exposure(GraphNode): unrendered_config: Dict[str, Any] = field(default_factory=dict) url: Optional[str] = None depends_on: DependsOn = field(default_factory=DependsOn) - refs: List[RefArgs] = field(default_factory=list) + refs: List[RefArgsResource] = field(default_factory=list) sources: List[List[str]] = field(default_factory=list) metrics: List[List[str]] = field(default_factory=list) created_at: float = field(default_factory=lambda: time.time()) @@ -1492,7 +1462,7 @@ def group(self): @dataclass class MetricInputMeasure(dbtClassMixin): name: str - filter: Optional[WhereFilterIntersection] = None + filter: Optional[WhereFilterIntersectionResource] = None alias: Optional[str] = None join_to_timespine: bool = False fill_nulls_with: Optional[int] = None @@ -1513,7 +1483,7 @@ class MetricTimeWindow(dbtClassMixin): @dataclass class MetricInput(dbtClassMixin): name: str - filter: Optional[WhereFilterIntersection] = None + filter: Optional[WhereFilterIntersectionResource] = None alias: Optional[str] = None offset_window: Optional[MetricTimeWindow] = None offset_to_grain: Optional[TimeGranularity] = None @@ -1561,8 +1531,8 @@ class Metric(GraphNode): label: str type: MetricType type_params: MetricTypeParams - filter: Optional[WhereFilterIntersection] = None - metadata: Optional[SourceFileMetadata] = None + filter: Optional[WhereFilterIntersectionResource] = None + metadata: Optional[SourceFileMetadataResource] = None resource_type: Literal[NodeType.Metric] meta: Dict[str, Any] = field(default_factory=dict) tags: List[str] = field(default_factory=list) @@ -1570,7 +1540,7 @@ class Metric(GraphNode): unrendered_config: Dict[str, Any] = field(default_factory=dict) sources: List[List[str]] = field(default_factory=list) depends_on: DependsOn = field(default_factory=DependsOn) - refs: List[RefArgs] = field(default_factory=list) + refs: List[RefArgsResource] = field(default_factory=list) metrics: List[List[str]] = field(default_factory=list) created_at: float = field(default_factory=lambda: time.time()) group: Optional[str] = None @@ -1670,9 +1640,9 @@ class SemanticModel(GraphNode): entities: Sequence[Entity] = field(default_factory=list) measures: Sequence[Measure] = field(default_factory=list) dimensions: Sequence[Dimension] = field(default_factory=list) - metadata: Optional[SourceFileMetadata] = None + metadata: Optional[SourceFileMetadataResource] = None depends_on: DependsOn = field(default_factory=DependsOn) - refs: List[RefArgs] = field(default_factory=list) + refs: List[RefArgsResource] = field(default_factory=list) created_at: float = field(default_factory=lambda: time.time()) config: SemanticModelConfig = field(default_factory=SemanticModelConfig) unrendered_config: Dict[str, Any] = field(default_factory=dict) @@ -1820,36 +1790,12 @@ def same_contents(self, old: Optional["SemanticModel"]) -> bool: # ==================================== -# SavedQuery and related classes +# SavedQuery # ==================================== @dataclass -class SavedQueryMandatory(GraphNode): - query_params: QueryParams - exports: List[Export] - - -@dataclass -class SavedQuery(NodeInfoMixin, SavedQueryMandatory): - description: Optional[str] = None - label: Optional[str] = None - metadata: Optional[SourceFileMetadata] = None - config: SavedQueryConfig = field(default_factory=SavedQueryConfig) - unrendered_config: Dict[str, Any] = field(default_factory=dict) - group: Optional[str] = None - depends_on: DependsOn = field(default_factory=DependsOn) - created_at: float = field(default_factory=lambda: time.time()) - refs: List[RefArgs] = field(default_factory=list) - - @property - def metrics(self) -> List[str]: - return self.query_params.metrics - - @property - def depends_on_nodes(self): - return self.depends_on.nodes - +class SavedQuery(NodeInfoMixin, GraphNode, SavedQueryResource): def same_metrics(self, old: "SavedQuery") -> bool: return self.query_params.metrics == old.query_params.metrics @@ -1872,12 +1818,18 @@ def same_group(self, old: "SavedQuery") -> bool: return self.group == old.group def same_exports(self, old: "SavedQuery") -> bool: + # TODO: This isn't currently used in `same_contents` (nor called anywhere else) if len(self.exports) != len(old.exports): return False # exports should be in the same order, so we zip them for easy iteration for (old_export, new_export) in zip(old.exports, self.exports): - if not new_export.same_contents(old_export): + if not ( + old_export.name == new_export.name + and old_export.config.export_as == new_export.config.export_as + and old_export.config.schema_name == new_export.config.schema_name + and old_export.config.alias == new_export.config.alias + ): return False return True diff --git a/core/dbt/contracts/graph/saved_queries.py b/core/dbt/contracts/graph/saved_queries.py deleted file mode 100644 index 64f99f90838..00000000000 --- a/core/dbt/contracts/graph/saved_queries.py +++ /dev/null @@ -1,53 +0,0 @@ -from __future__ import annotations - -from dataclasses import dataclass -from dbt.contracts.graph.semantic_layer_common import WhereFilterIntersection -from dbt_common.dataclass_schema import dbtClassMixin -from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType -from typing import List, Optional - - -@dataclass -class ExportConfig(dbtClassMixin): - """Nested configuration attributes for exports.""" - - export_as: ExportDestinationType - schema_name: Optional[str] = None - alias: Optional[str] = None - - -@dataclass -class Export(dbtClassMixin): - """Configuration for writing query results to a table.""" - - name: str - config: ExportConfig - - def same_name(self, old: Export) -> bool: - return self.name == old.name - - def same_export_as(self, old: Export) -> bool: - return self.config.export_as == old.config.export_as - - def same_schema_name(self, old: Export) -> bool: - return self.config.schema_name == old.config.schema_name - - def same_alias(self, old: Export) -> bool: - return self.config.alias == old.config.alias - - def same_contents(self, old: Export) -> bool: - return ( - self.same_name(old) - and self.same_export_as(old) - and self.same_schema_name(old) - and self.same_alias(old) - ) - - -@dataclass -class QueryParams(dbtClassMixin): - """The query parameters for the saved query""" - - metrics: List[str] - group_by: List[str] - where: Optional[WhereFilterIntersection] diff --git a/core/dbt/contracts/graph/semantic_models.py b/core/dbt/contracts/graph/semantic_models.py index 4984ab0b1da..53394d02f80 100644 --- a/core/dbt/contracts/graph/semantic_models.py +++ b/core/dbt/contracts/graph/semantic_models.py @@ -12,33 +12,10 @@ EntityType, TimeGranularity, ) +from dbt.artifacts.resources import SourceFileMetadata from typing import List, Optional -@dataclass -class FileSlice(dbtClassMixin): - """Provides file slice level context about what something was created from. - - Implementation of the dbt-semantic-interfaces `FileSlice` protocol - """ - - filename: str - content: str - start_line_number: int - end_line_number: int - - -@dataclass -class SourceFileMetadata(dbtClassMixin): - """Provides file context about what something was created from. - - Implementation of the dbt-semantic-interfaces `Metadata` protocol - """ - - repo_file_path: str - file_slice: FileSlice - - @dataclass class Defaults(dbtClassMixin): agg_time_dimension: Optional[str] = None diff --git a/core/dbt/contracts/graph/unparsed.py b/core/dbt/contracts/graph/unparsed.py index 8e751e71a4a..8f16b14bdb5 100644 --- a/core/dbt/contracts/graph/unparsed.py +++ b/core/dbt/contracts/graph/unparsed.py @@ -29,7 +29,7 @@ from dbt.exceptions import ParsingError from dbt_semantic_interfaces.type_enums import ConversionCalculationType -from dbt.artifacts.resources import Docs, MacroArgument, Owner +from dbt.artifacts.resources import Docs, MacroArgument, NodeVersion, Owner from dataclasses import dataclass, field from datetime import timedelta @@ -138,9 +138,6 @@ class HasConfig: config: Dict[str, Any] = field(default_factory=dict) -NodeVersion = Union[str, float] - - @dataclass class UnparsedVersion(dbtClassMixin): v: NodeVersion diff --git a/core/dbt/parser/common.py b/core/dbt/parser/common.py index 8dc2ab2e8ad..935b70b91c6 100644 --- a/core/dbt/parser/common.py +++ b/core/dbt/parser/common.py @@ -1,3 +1,4 @@ +from dbt.artifacts.resources import NodeVersion from dbt_common.contracts.constraints import ColumnLevelConstraint, ConstraintType from dbt.contracts.graph.unparsed import ( HasColumnProps, @@ -8,7 +9,7 @@ UnparsedExposure, UnparsedModelUpdate, ) -from dbt.contracts.graph.unparsed import NodeVersion, HasColumnTests, HasColumnDocs +from dbt.contracts.graph.unparsed import HasColumnTests, HasColumnDocs from dbt.contracts.graph.nodes import UnpatchedSourceDefinition, ColumnInfo from dbt.parser.search import FileBlock from typing import List, Dict, Any, TypeVar, Generic, Union, Optional diff --git a/core/dbt/parser/generic_test_builders.py b/core/dbt/parser/generic_test_builders.py index 862f2a3bdc9..bc9d75fc3c5 100644 --- a/core/dbt/parser/generic_test_builders.py +++ b/core/dbt/parser/generic_test_builders.py @@ -9,10 +9,10 @@ List, ) +from dbt.artifacts.resources import NodeVersion from dbt.clients.jinja import get_rendered, GENERIC_TEST_KWARGS_NAME from dbt.contracts.graph.nodes import UnpatchedSourceDefinition from dbt.contracts.graph.unparsed import ( - NodeVersion, UnparsedNodeUpdate, UnparsedModelUpdate, ) diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py index 96d1a9ac5c2..c8ce29c8719 100644 --- a/core/dbt/parser/manifest.py +++ b/core/dbt/parser/manifest.py @@ -108,7 +108,7 @@ ModelNode, NodeRelation, ) -from dbt.contracts.graph.unparsed import NodeVersion +from dbt.artifacts.resources import NodeVersion from dbt.artifacts.schemas.base import Writable from dbt.exceptions import ( TargetNotFoundError, diff --git a/core/dbt/parser/models.py b/core/dbt/parser/models.py index 774e83961dc..b5cbba5583a 100644 --- a/core/dbt/parser/models.py +++ b/core/dbt/parser/models.py @@ -1,6 +1,7 @@ from copy import deepcopy +from dbt.artifacts.resources import RefArgs from dbt.context.context_config import ContextConfig -from dbt.contracts.graph.nodes import ModelNode, RefArgs +from dbt.contracts.graph.nodes import ModelNode from dbt_common.events.base_types import EventLevel from dbt_common.events.types import Note from dbt_common.events.functions import fire_event_if_test diff --git a/core/dbt/parser/schema_generic_tests.py b/core/dbt/parser/schema_generic_tests.py index 20abf9a312f..be1f4a6e939 100644 --- a/core/dbt/parser/schema_generic_tests.py +++ b/core/dbt/parser/schema_generic_tests.py @@ -3,10 +3,11 @@ import os from typing import List, Dict, Optional, Union, Any +from dbt.artifacts.resources import NodeVersion, RefArgs from dbt.parser.base import SimpleParser from dbt.parser.generic_test_builders import TestBuilder from dbt.parser.search import FileBlock -from dbt.context.providers import RefArgs, generate_test_context +from dbt.context.providers import generate_test_context from dbt.parser.common import ( TestBlock, Testable, @@ -15,7 +16,7 @@ VersionedTestBlock, trimmed, ) -from dbt.contracts.graph.unparsed import UnparsedNodeUpdate, NodeVersion, UnparsedColumn +from dbt.contracts.graph.unparsed import UnparsedNodeUpdate, UnparsedColumn from dbt.contracts.graph.nodes import ( GenericTestNode, UnpatchedSourceDefinition, diff --git a/core/dbt/parser/schema_yaml_readers.py b/core/dbt/parser/schema_yaml_readers.py index 70b9e6f3b7b..fceafb39016 100644 --- a/core/dbt/parser/schema_yaml_readers.py +++ b/core/dbt/parser/schema_yaml_readers.py @@ -19,7 +19,6 @@ UnparsedSemanticModel, UnparsedConversionTypeParams, ) -from dbt.contracts.graph.model_config import SavedQueryConfig from dbt.contracts.graph.nodes import ( Exposure, Group, @@ -32,8 +31,14 @@ SavedQuery, ConversionTypeParams, ) -from dbt.contracts.graph.saved_queries import Export, ExportConfig, QueryParams -from dbt.contracts.graph.semantic_layer_common import WhereFilter, WhereFilterIntersection +from dbt.artifacts.resources import ( + Export, + ExportConfig, + QueryParams, + SavedQueryConfig, + WhereFilter, + WhereFilterIntersection, +) from dbt.contracts.graph.semantic_models import ( Dimension, DimensionTypeParams, diff --git a/core/dbt/plugins/manifest.py b/core/dbt/plugins/manifest.py index 112cd1565b3..9b1080e3afa 100644 --- a/core/dbt/plugins/manifest.py +++ b/core/dbt/plugins/manifest.py @@ -6,7 +6,7 @@ # all these are just exports, they need "noqa" so flake8 will not complain. from dbt.contracts.graph.manifest import Manifest # noqa from dbt.node_types import AccessType, NodeType # noqa -from dbt.contracts.graph.unparsed import NodeVersion # noqa +from dbt.artifacts.resources import NodeVersion # noqa from dbt.graph.graph import UniqueId # noqa diff --git a/tests/functional/experimental_parser/test_all_experimental_parser.py b/tests/functional/experimental_parser/test_all_experimental_parser.py index b426c308bb5..8d5f138dd43 100644 --- a/tests/functional/experimental_parser/test_all_experimental_parser.py +++ b/tests/functional/experimental_parser/test_all_experimental_parser.py @@ -2,8 +2,8 @@ from dbt.tests.util import run_dbt, run_dbt_and_capture +from dbt.artifacts.resources import RefArgs from dbt.contracts.graph.manifest import Manifest -from dbt.contracts.graph.nodes import RefArgs import os diff --git a/tests/unit/test_contracts_graph_parsed.py b/tests/unit/test_contracts_graph_parsed.py index 64ebea23230..69e64e6c1d2 100644 --- a/tests/unit/test_contracts_graph_parsed.py +++ b/tests/unit/test_contracts_graph_parsed.py @@ -4,6 +4,7 @@ from hypothesis import given from hypothesis.strategies import builds, lists +from dbt.artifacts.resources import RefArgs from dbt.node_types import NodeType, AccessType from dbt.contracts.files import FileHash from dbt.contracts.graph.model_config import ( @@ -38,7 +39,6 @@ Owner, TestMetadata, SemanticModel, - RefArgs, ) from dbt.contracts.graph.semantic_models import Dimension, Entity, Measure from dbt.contracts.graph.unparsed import ( diff --git a/tests/unit/test_graph_selector_methods.py b/tests/unit/test_graph_selector_methods.py index db5c2f185e6..9726c4ab2e9 100644 --- a/tests/unit/test_graph_selector_methods.py +++ b/tests/unit/test_graph_selector_methods.py @@ -31,7 +31,7 @@ UnitTestDefinition, ) from dbt.contracts.graph.manifest import Manifest, ManifestMetadata -from dbt.contracts.graph.saved_queries import QueryParams +from dbt.artifacts.resources import QueryParams from dbt.contracts.graph.unparsed import ( ExposureType, Owner, diff --git a/tests/unit/test_manifest.py b/tests/unit/test_manifest.py index 89629242f1a..a8248efef7c 100644 --- a/tests/unit/test_manifest.py +++ b/tests/unit/test_manifest.py @@ -27,9 +27,12 @@ MetricInputMeasure, MetricTypeParams, Group, +) +from dbt.artifacts.resources import ( RefArgs, + WhereFilter, + WhereFilterIntersection, ) -from dbt.contracts.graph.semantic_layer_common import WhereFilter, WhereFilterIntersection from dbt.contracts.graph.unparsed import ( ExposureType, Owner, diff --git a/tests/unit/test_parser.py b/tests/unit/test_parser.py index c6766f2d53c..ef750cb5915 100644 --- a/tests/unit/test_parser.py +++ b/tests/unit/test_parser.py @@ -8,6 +8,7 @@ import dbt.flags import dbt.parser from dbt import tracking +from dbt.artifacts.resources import RefArgs from dbt.context.context_config import ContextConfig from dbt.contracts.files import SourceFile, FileHash, FilePath, SchemaSourceFile from dbt.contracts.graph.manifest import Manifest @@ -20,7 +21,6 @@ SnapshotNode, AnalysisNode, UnpatchedSourceDefinition, - RefArgs, ) from dbt.exceptions import CompilationError, ParsingError from dbt.node_types import NodeType diff --git a/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py b/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py index 8a3f588d69f..0c8700c04fa 100644 --- a/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py +++ b/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py @@ -13,18 +13,20 @@ SavedQuery, SemanticModel, ) -from dbt.contracts.graph.semantic_layer_common import WhereFilter +from dbt.artifacts.resources import ( + FileSlice, + SourceFileMetadata, + WhereFilter, +) from dbt.contracts.graph.semantic_models import ( Dimension, DimensionTypeParams, DimensionValidityParams, Defaults, Entity, - FileSlice, Measure, MeasureAggregationParameters, NonAdditiveDimension, - SourceFileMetadata, ) from dbt.node_types import NodeType from dbt_semantic_interfaces.protocols import (