Skip to content

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Oct 11, 2023
1 parent 3914457 commit 37ac216
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
12 changes: 4 additions & 8 deletions dlt/common/normalizers/json/relational.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]

Expand Down Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions dlt/extract/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 37ac216

Please sign in to comment.