Skip to content

Commit

Permalink
Fixes open-metadata#16591 : DBT Glossary Term linking Independent fro…
Browse files Browse the repository at this point in the history
…m Tag rule (open-metadata#16745)
  • Loading branch information
SumanMaharana authored Jun 21, 2024
1 parent 5bd48fc commit f425d9b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def process_dbt_meta(self, manifest_meta):
get_tag_labels(
metadata=self.metadata,
tags=dbt_meta_info.openmetadata.glossary,
include_tags=self.source_config.includeTags,
include_tags=True,
tag_type=GlossaryTerm,
)
or []
Expand All @@ -734,7 +734,7 @@ def process_dbt_meta(self, manifest_meta):
metadata=self.metadata,
tags=[tier_fqn.split(fqn.FQN_SEPARATOR)[-1]],
classification_name=tier_fqn.split(fqn.FQN_SEPARATOR)[0],
include_tags=self.source_config.includeTags,
include_tags=True,
)
or []
)
Expand Down
24 changes: 21 additions & 3 deletions ingestion/tests/unit/resources/datasets/manifest_v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
"model_tag_two"
],
"meta": {
"owner": "aaron_johnson0"
"owner": "aaron_johnson0",
"openmetadata": {
"glossary": [
"Test_Glossary.term_one",
"Test_Glossary.term_two.nested_term.more_nested_term"
]
}
},
"materialized": "table",
"incremental_strategy": null,
Expand Down Expand Up @@ -114,7 +120,13 @@
}
},
"meta": {
"owner": "aaron_johnson0"
"owner": "aaron_johnson0",
"openmetadata": {
"glossary": [
"Test_Glossary.term_one",
"Test_Glossary.term_two.nested_term.more_nested_term"
]
}
},
"docs": {
"show": true,
Expand All @@ -131,7 +143,13 @@
"model_tag_two"
],
"meta": {
"owner": "aaron_johnson0"
"owner": "aaron_johnson0",
"openmetadata": {
"glossary": [
"Test_Glossary.term_one",
"Test_Glossary.term_two.nested_term.more_nested_term"
]
}
}
},
"created_at": 1673981809.96386,
Expand Down
44 changes: 44 additions & 0 deletions ingestion/tests/unit/test_dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@
),
]

MOCK_GLOASSARY_LABELS = [
TagLabel(
tagFQN="Test_Glossary.term_one",
labelType=LabelType.Automated,
state=State.Suggested,
source=TagSource.Glossary,
),
TagLabel(
tagFQN="Test_Glossary.term_two.nested_term.more_nested_term",
labelType=LabelType.Automated,
state=State.Suggested,
source=TagSource.Glossary,
),
]


class DbtUnitTest(TestCase):
"""
Expand Down Expand Up @@ -511,3 +526,32 @@ def check_yield_datamodel(self, dbt_objects, expected_data_models):
zip(expected_data_models, data_model_list)
):
self.assertEqual(expected, original)

@patch("metadata.utils.tag_utils.get_tag_label")
def test_dbt_glossary_tiers(self, get_tag_label):
get_tag_label.side_effect = [
TagLabel(
tagFQN="Test_Glossary.term_one",
labelType=LabelType.Automated.value,
state=State.Suggested.value,
source=TagSource.Glossary.value,
),
TagLabel(
tagFQN="Test_Glossary.term_two.nested_term.more_nested_term",
labelType=LabelType.Automated.value,
state=State.Suggested.value,
source=TagSource.Glossary.value,
),
]

_, dbt_objects = self.get_dbt_object_files(
mock_manifest=MOCK_SAMPLE_MANIFEST_V8
)
manifest_node = dbt_objects.dbt_manifest.nodes.get(
"model.jaffle_shop.customers"
)
dbt_meta_tags = self.dbt_source_obj.process_dbt_meta(
manifest_meta=manifest_node.meta
)

self.assertEqual(dbt_meta_tags, MOCK_GLOASSARY_LABELS)

0 comments on commit f425d9b

Please sign in to comment.