From 37ac216239ec115c4fe0833d8939237ba4217293 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 11 Oct 2023 11:56:56 +0200 Subject: [PATCH] small change --- dlt/common/normalizers/json/relational.py | 12 ++++-------- dlt/extract/source.py | 12 +++++------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/dlt/common/normalizers/json/relational.py b/dlt/common/normalizers/json/relational.py index b1e600ca94..58b798e7c7 100644 --- a/dlt/common/normalizers/json/relational.py +++ b/dlt/common/normalizers/json/relational.py @@ -30,7 +30,7 @@ class TDataItemRowChild(TDataItemRow, total=False): value: Any # for lists of simple types -class RelationalNormalizerConfigPropagation(TypedDict, total=True): +class RelationalNormalizerConfigPropagation(TypedDict, total=False): root: Optional[Mapping[str, TColumnName]] tables: Optional[Mapping[str, Mapping[str, TColumnName]]] @@ -261,16 +261,12 @@ def extend_schema(self) -> None: # for every table with the write disposition merge, we propagate the root_key for table_name, table in self.schema.tables.items(): if not table.get("parent") and table["write_disposition"] == "merge": - prop_config: RelationalNormalizerConfigPropagation = { - "root": { - }, + DataItemNormalizer.update_normalizer_config(self.schema, {"propagation": { "tables": { - table_name: { + table_name: { "_dlt_id": TColumnName("_dlt_root_id") } - } - } - DataItemNormalizer.update_normalizer_config(self.schema, {"propagation": prop_config}) + }}}) def normalize_data_item(self, item: TDataItem, load_id: str, table_name: str) -> TNormalizedRowIterator: # wrap items that are not dictionaries in dictionary, otherwise they cannot be processed by the JSON normalizer diff --git a/dlt/extract/source.py b/dlt/extract/source.py index d375cc0d98..f0691327da 100644 --- a/dlt/extract/source.py +++ b/dlt/extract/source.py @@ -697,13 +697,11 @@ def root_key(self) -> bool: @root_key.setter def root_key(self, value: bool) -> None: if value is True: - propagation_config: RelationalNormalizerConfigPropagation = { - "root": { - "_dlt_id": TColumnName("_dlt_root_id") - }, - "tables": {} - } - RelationalNormalizer.update_normalizer_config(self._schema, {"propagation": propagation_config}) + RelationalNormalizer.update_normalizer_config(self._schema, + {"propagation": { + "root": { + "_dlt_id": TColumnName("_dlt_root_id") + }}}) else: if self.root_key: propagation_config = RelationalNormalizer.get_normalizer_config(self._schema)["propagation"]