From 4a88879869cecc6125f8077c1163a46c61eee79f Mon Sep 17 00:00:00 2001 From: Antonio Papa Date: Mon, 22 Apr 2024 08:28:45 -0400 Subject: [PATCH] Allows a snapshot to have a list as a unique_key --- core/dbt/artifacts/resources/v1/snapshot.py | 2 +- core/dbt/contracts/graph/model_config.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/dbt/artifacts/resources/v1/snapshot.py b/core/dbt/artifacts/resources/v1/snapshot.py index 3eceb9bb1d2..4c9cbea27c5 100644 --- a/core/dbt/artifacts/resources/v1/snapshot.py +++ b/core/dbt/artifacts/resources/v1/snapshot.py @@ -10,11 +10,11 @@ class SnapshotConfig(NodeConfig): materialized: str = "snapshot" strategy: Optional[str] = None - unique_key: Optional[str] = None target_schema: Optional[str] = None target_database: Optional[str] = None updated_at: Optional[str] = None # Not using Optional because of serialization issues with a Union of str and List[str] + unique_key: Union[str, List[str], None] = None check_cols: Union[str, List[str], None] = None @classmethod diff --git a/core/dbt/contracts/graph/model_config.py b/core/dbt/contracts/graph/model_config.py index b45c313327c..8181f8b34bd 100644 --- a/core/dbt/contracts/graph/model_config.py +++ b/core/dbt/contracts/graph/model_config.py @@ -1,5 +1,5 @@ from dataclasses import field, dataclass -from typing import Any, List, Optional, Dict, Type +from typing import Any, List, Optional, Dict, Type, Union from dbt.artifacts.resources import ( ExposureConfig, @@ -42,7 +42,7 @@ class UnitTestNodeConfig(NodeConfig): @dataclass class EmptySnapshotConfig(NodeConfig): materialized: str = "snapshot" - unique_key: Optional[str] = None # override NodeConfig unique_key definition + unique_key: Union[str, List[str], None] = None # override NodeConfig unique_key definition RESOURCE_TYPES: Dict[NodeType, Type[BaseConfig]] = {