Skip to content

Commit

Permalink
Move SavedQueryConfig to dbt/artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Jan 26, 2024
1 parent 59cdffe commit 8ff0769
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
1 change: 1 addition & 0 deletions core/dbt/artifacts/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Export,
ExportConfig,
QueryParams,
SavedQueryConfig,
SavedQueryMandatory,
)
from dbt.artifacts.resources.v1.semantic_layer_components import (
Expand Down
28 changes: 26 additions & 2 deletions core/dbt/artifacts/resources/v1/saved_query.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field
from dbt.artifacts.resources.base import GraphArtifactNode
from dbt.artifacts.resources.v1.semantic_layer_components import 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 List, Optional
from typing import Any, Dict, List, Optional


@dataclass
Expand Down Expand Up @@ -34,6 +35,29 @@ class QueryParams(dbtClassMixin):
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(GraphArtifactNode):
query_params: QueryParams
Expand Down
25 changes: 1 addition & 24 deletions core/dbt/contracts/graph/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@
SemanticModelConfig,
UnitTestConfig,
UnitTestNodeConfig,
SavedQueryConfig,
)

from dbt.artifacts.resources import (
BaseArtifactNode,
Documentation as DocumentationContract,
SavedQueryConfig,
SavedQueryMandatory as SavedQueryMandatoryArtifact,
SourceFileMetadata as SourceFileMetadataArtifact,
WhereFilterIntersection as WhereFilterIntersectionArtifact,
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/schema_yaml_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
UnparsedSemanticModel,
UnparsedConversionTypeParams,
)
from dbt.contracts.graph.model_config import SavedQueryConfig
from dbt.contracts.graph.nodes import (
Exposure,
Group,
Expand All @@ -36,6 +35,7 @@
Export,
ExportConfig,
QueryParams,
SavedQueryConfig,
WhereFilter,
WhereFilterIntersection,
)
Expand Down

0 comments on commit 8ff0769

Please sign in to comment.