Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 10a7e0c

Browse files
authored
check if test_metadata exists first (#734)
1 parent 9e6bfeb commit 10a7e0c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

data_diff/dbt_parser.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,19 +483,20 @@ def get_unique_columns(self) -> Dict[str, Set[str]]:
483483
continue
484484

485485
model_node = manifest.nodes[uid]
486-
if node.test_metadata.name == "unique":
487-
column_name: str = node.test_metadata.kwargs["column_name"]
488-
for col in self._parse_concat_pk_definition(column_name):
489-
if model_node is None or col in model_node.columns:
490-
# skip anything that is not a column.
491-
# for example, string literals used in concat
492-
# like "pk1 || '-' || pk2"
486+
if node.test_metadata:
487+
if node.test_metadata.name == "unique":
488+
column_name: str = node.test_metadata.kwargs["column_name"]
489+
for col in self._parse_concat_pk_definition(column_name):
490+
if model_node is None or col in model_node.columns:
491+
# skip anything that is not a column.
492+
# for example, string literals used in concat
493+
# like "pk1 || '-' || pk2"
494+
cols_by_uid[uid].add(col)
495+
496+
elif node.test_metadata.name == "unique_combination_of_columns":
497+
for col in node.test_metadata.kwargs["combination_of_columns"]:
493498
cols_by_uid[uid].add(col)
494499

495-
if node.test_metadata.name == "unique_combination_of_columns":
496-
for col in node.test_metadata.kwargs["combination_of_columns"]:
497-
cols_by_uid[uid].add(col)
498-
499500
except (KeyError, IndexError, TypeError) as e:
500501
logger.warning("Failure while finding unique cols: %s", e)
501502

0 commit comments

Comments
 (0)