From 7acd049a38a106e8fd69fb180a79dda03001bb40 Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Thu, 12 Dec 2024 14:36:08 -0800 Subject: [PATCH] remove extra when serialize --- core/dbt/artifacts/resources/v1/model.py | 6 ++++++ core/dbt/contracts/graph/manifest.py | 1 - core/dbt/contracts/graph/nodes.py | 2 -- tests/unit/contracts/graph/test_manifest.py | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/dbt/artifacts/resources/v1/model.py b/core/dbt/artifacts/resources/v1/model.py index e80b88de9dd..adcbf069464 100644 --- a/core/dbt/artifacts/resources/v1/model.py +++ b/core/dbt/artifacts/resources/v1/model.py @@ -52,4 +52,10 @@ def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None): dct = super().__post_serialize__(dct, context) if context and context.get("artifact") and "defer_relation" in dct: del dct["defer_relation"] + + # delete extra keys that should't be serialized + if self.extra: + for key, _ in self.extra.items(): + if key in dct: + del dct[key] return dct diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index e53ae1a48b1..0168abe8fd8 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -1206,7 +1206,6 @@ def writable_manifest(self) -> "WritableManifest": self.build_parent_and_child_maps() self.build_group_map() self.fill_tracking_metadata() - return WritableManifest( nodes=self._map_nodes_to_map_resources(self.nodes), sources=self._map_nodes_to_map_resources(self.sources), diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 030ab783dfd..e919cb9fff1 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -475,8 +475,6 @@ def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None): del dct["_has_this"] if "previous_batch_results" in dct: del dct["previous_batch_results"] - if "batch" in dct: - del dct["batch"] return dct @classmethod diff --git a/tests/unit/contracts/graph/test_manifest.py b/tests/unit/contracts/graph/test_manifest.py index 0f3a80e5039..3505ee80037 100644 --- a/tests/unit/contracts/graph/test_manifest.py +++ b/tests/unit/contracts/graph/test_manifest.py @@ -96,6 +96,7 @@ "deprecation_date", "defer_relation", "time_spine", + "batch", } )