Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop committed Nov 2, 2023
1 parent 1d3d86f commit 546abdd
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core/dbt/parser/partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ def _handle_element_change(
# Take a "section" of the schema file yaml dictionary from saved and new schema files
# and determine which parts have changed
def get_diff_for(self, key, saved_yaml_dict, new_yaml_dict):
dict_name = "name"
if key in saved_yaml_dict or key in new_yaml_dict:
saved_elements = saved_yaml_dict[key] if key in saved_yaml_dict else []
new_elements = new_yaml_dict[key] if key in new_yaml_dict else []
Expand All @@ -722,9 +721,9 @@ def get_diff_for(self, key, saved_yaml_dict, new_yaml_dict):
new_elements_by_name = {}
# sources have two part names?
for element in saved_elements:
saved_elements_by_name[element[dict_name]] = element
saved_elements_by_name[element["name"]] = element
for element in new_elements:
new_elements_by_name[element[dict_name]] = element
new_elements_by_name[element["name"]] = element

# now determine which elements, by name, are added, deleted or changed
saved_element_names = set(saved_elements_by_name.keys())
Expand Down Expand Up @@ -754,7 +753,6 @@ def get_diff_for(self, key, saved_yaml_dict, new_yaml_dict):
# flag indicates that we're processing a schema file, so if a matching
# patch has already been scheduled, replace it.
def merge_patch(self, schema_file, key, patch, new_patch=False):
elem_name = "name"
if schema_file.pp_dict is None:
schema_file.pp_dict = {}
pp_dict = schema_file.pp_dict
Expand All @@ -764,7 +762,7 @@ def merge_patch(self, schema_file, key, patch, new_patch=False):
# check that this patch hasn't already been saved
found_elem = None
for elem in pp_dict[key]:
if elem["name"] == patch[elem_name]:
if elem["name"] == patch["name"]:
found_elem = elem
if not found_elem:
pp_dict[key].append(patch)
Expand All @@ -773,7 +771,7 @@ def merge_patch(self, schema_file, key, patch, new_patch=False):
pp_dict[key].remove(found_elem)
pp_dict[key].append(patch)

schema_file.delete_from_env_vars(key, patch[elem_name])
schema_file.delete_from_env_vars(key, patch["name"])
self.add_to_pp_files(schema_file)

# For model, seed, snapshot, analysis schema dictionary keys,
Expand Down

0 comments on commit 546abdd

Please sign in to comment.