diff --git a/dbt_semantic_interfaces/implementations/elements/measure.py b/dbt_semantic_interfaces/implementations/elements/measure.py index 3c7407cc..5da1da4f 100644 --- a/dbt_semantic_interfaces/implementations/elements/measure.py +++ b/dbt_semantic_interfaces/implementations/elements/measure.py @@ -9,6 +9,7 @@ from dbt_semantic_interfaces.implementations.metadata import PydanticMetadata from dbt_semantic_interfaces.references import MeasureReference from dbt_semantic_interfaces.type_enums import AggregationType +from dsi_pydantic_shim import Field class PydanticNonAdditiveDimensionParameters(HashableBaseModel): @@ -21,7 +22,7 @@ class PydanticNonAdditiveDimensionParameters(HashableBaseModel): # Optional Fields window_choice: AggregationType = AggregationType.MIN - window_groupings: List[str] = [] + window_groupings: List[str] = Field(default_factory=list) class PydanticMeasureAggregationParameters(HashableBaseModel): diff --git a/dbt_semantic_interfaces/implementations/project_configuration.py b/dbt_semantic_interfaces/implementations/project_configuration.py index 1bceecc9..f04364a9 100644 --- a/dbt_semantic_interfaces/implementations/project_configuration.py +++ b/dbt_semantic_interfaces/implementations/project_configuration.py @@ -20,7 +20,7 @@ ) from dbt_semantic_interfaces.protocols import ProtocolHint from dbt_semantic_interfaces.protocols.project_configuration import ProjectConfiguration -from dsi_pydantic_shim import validator +from dsi_pydantic_shim import Field, validator class PydanticProjectConfiguration(HashableBaseModel, ModelWithMetadataParsing, ProtocolHint[ProjectConfiguration]): @@ -30,10 +30,10 @@ class PydanticProjectConfiguration(HashableBaseModel, ModelWithMetadataParsing, def _implements_protocol(self) -> ProjectConfiguration: return self - time_spine_table_configurations: List[PydanticTimeSpineTableConfiguration] = [] + time_spine_table_configurations: List[PydanticTimeSpineTableConfiguration] = Field(default_factory=list) metadata: Optional[PydanticMetadata] = None dsi_package_version: PydanticSemanticVersion = UNKNOWN_VERSION_SENTINEL - time_spines: List[PydanticTimeSpine] = [] + time_spines: List[PydanticTimeSpine] = Field(default_factory=list) @validator("dsi_package_version", always=True) @classmethod diff --git a/dbt_semantic_interfaces/implementations/saved_query.py b/dbt_semantic_interfaces/implementations/saved_query.py index 7d7df23d..0c6da416 100644 --- a/dbt_semantic_interfaces/implementations/saved_query.py +++ b/dbt_semantic_interfaces/implementations/saved_query.py @@ -18,6 +18,7 @@ SavedQuery, SavedQueryQueryParams, ) +from dsi_pydantic_shim import Field class PydanticSavedQueryQueryParams(HashableBaseModel, ProtocolHint[SavedQueryQueryParams]): @@ -28,8 +29,8 @@ def _implements_protocol(self) -> SavedQueryQueryParams: return self metrics: List[str] - group_by: List[str] = [] - order_by: List[str] = [] + group_by: List[str] = Field(default_factory=list) + order_by: List[str] = Field(default_factory=list) limit: Optional[int] = None where: Optional[PydanticWhereFilterIntersection] = None @@ -46,4 +47,4 @@ def _implements_protocol(self) -> SavedQuery: description: Optional[str] = None metadata: Optional[PydanticMetadata] = None label: Optional[str] = None - exports: List[PydanticExport] = [] + exports: List[PydanticExport] = Field(default_factory=list) diff --git a/dbt_semantic_interfaces/implementations/semantic_manifest.py b/dbt_semantic_interfaces/implementations/semantic_manifest.py index c8ce48ae..55402cf0 100644 --- a/dbt_semantic_interfaces/implementations/semantic_manifest.py +++ b/dbt_semantic_interfaces/implementations/semantic_manifest.py @@ -10,6 +10,7 @@ from dbt_semantic_interfaces.implementations.saved_query import PydanticSavedQuery from dbt_semantic_interfaces.implementations.semantic_model import PydanticSemanticModel from dbt_semantic_interfaces.protocols import ProtocolHint, SemanticManifest +from dsi_pydantic_shim import Field class PydanticSemanticManifest(HashableBaseModel, ProtocolHint[SemanticManifest]): @@ -22,4 +23,4 @@ def _implements_protocol(self) -> SemanticManifest: semantic_models: List[PydanticSemanticModel] metrics: List[PydanticMetric] project_configuration: PydanticProjectConfiguration - saved_queries: List[PydanticSavedQuery] = [] + saved_queries: List[PydanticSavedQuery] = Field(default_factory=list) diff --git a/dbt_semantic_interfaces/implementations/semantic_model.py b/dbt_semantic_interfaces/implementations/semantic_model.py index 9ce62775..eca8d6fd 100644 --- a/dbt_semantic_interfaces/implementations/semantic_model.py +++ b/dbt_semantic_interfaces/implementations/semantic_model.py @@ -59,9 +59,9 @@ def _implements_protocol(self) -> SemanticModel: node_relation: PydanticNodeRelation primary_entity: Optional[str] - entities: Sequence[PydanticEntity] = [] - measures: Sequence[PydanticMeasure] = [] - dimensions: Sequence[PydanticDimension] = [] + entities: Sequence[PydanticEntity] = Field(default_factory=list) + measures: Sequence[PydanticMeasure] = Field(default_factory=list) + dimensions: Sequence[PydanticDimension] = Field(default_factory=list) label: Optional[str] = None metadata: Optional[PydanticMetadata] diff --git a/dbt_semantic_interfaces/implementations/time_spine.py b/dbt_semantic_interfaces/implementations/time_spine.py index dd249ff2..b010d3d2 100644 --- a/dbt_semantic_interfaces/implementations/time_spine.py +++ b/dbt_semantic_interfaces/implementations/time_spine.py @@ -13,6 +13,7 @@ TimeSpinePrimaryColumn, ) from dbt_semantic_interfaces.type_enums import TimeGranularity +from dsi_pydantic_shim import Field class PydanticTimeSpinePrimaryColumn(HashableBaseModel, ProtocolHint[TimeSpinePrimaryColumn]): # noqa: D101 @@ -42,4 +43,4 @@ def _implements_protocol(self) -> TimeSpine: node_relation: PydanticNodeRelation primary_column: PydanticTimeSpinePrimaryColumn - custom_granularities: Sequence[PydanticTimeSpineCustomGranularityColumn] = [] + custom_granularities: Sequence[PydanticTimeSpineCustomGranularityColumn] = Field(default_factory=list) diff --git a/tests/test_implements_satisfy_protocols.py b/tests/test_implements_satisfy_protocols.py index 44b34a3b..b37b5ca7 100644 --- a/tests/test_implements_satisfy_protocols.py +++ b/tests/test_implements_satisfy_protocols.py @@ -30,7 +30,10 @@ from dbt_semantic_interfaces.implementations.project_configuration import ( PydanticProjectConfiguration, ) -from dbt_semantic_interfaces.implementations.saved_query import PydanticSavedQuery +from dbt_semantic_interfaces.implementations.saved_query import ( + PydanticSavedQuery, + PydanticSavedQueryQueryParams, +) from dbt_semantic_interfaces.implementations.semantic_manifest import ( PydanticSemanticManifest, ) @@ -123,7 +126,7 @@ SAVED_QUERY_STRATEGY = builds( PydanticSavedQuery, - group_by=from_type(List[str]), + query_params=builds(PydanticSavedQueryQueryParams), where=from_type(List[PydanticWhereFilter]), description=OPTIONAL_STR_STRATEGY, metadata=OPTIONAL_METADATA_STRATEGY,