Skip to content

Commit 20e2cc7

Browse files
authored
fix(ingest/csv): add support multiple ownership type for the same dataset (#10287)
1 parent f860f79 commit 20e2cc7

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

metadata-ingestion/src/datahub/ingestion/source/csv_enricher.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,19 @@ def get_resource_owners_work_unit(
228228
# If we want to overwrite or there are no existing tags, create a new GlobalTags object
229229
current_ownership = OwnershipClass(owners, lastModified=get_audit_stamp())
230230
else:
231-
current_owner_urns: Set[str] = set(
232-
[owner.owner for owner in current_ownership.owners]
233-
)
234-
owners_filtered: List[OwnerClass] = [
235-
owner for owner in owners if owner.owner not in current_owner_urns
236-
]
231+
owners_filtered: List[OwnerClass] = []
232+
for owner in owners:
233+
owner_exists = False
234+
for current_owner in current_ownership.owners:
235+
if (
236+
owner.owner == current_owner.owner
237+
and owner.type == current_owner.type
238+
):
239+
owner_exists = True
240+
break
241+
if not owner_exists:
242+
owners_filtered.append(owner)
243+
237244
# If there are no new owners to add, we don't need to emit a work unit.
238245
if len(owners_filtered) <= 0:
239246
return None

metadata-ingestion/tests/integration/csv-enricher/csv_enricher_golden.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,36 @@
306306
"runId": "test-csv-enricher"
307307
}
308308
},
309+
{
310+
"entityType": "dashboard",
311+
"entityUrn": "urn:li:dashboard:(looker,baz)",
312+
"changeType": "UPSERT",
313+
"aspectName": "ownership",
314+
"aspect": {
315+
"json": {
316+
"owners": [
317+
{
318+
"owner": "urn:li:corpuser:datahub",
319+
"type": "BUSINESS_OWNER"
320+
},
321+
{
322+
"owner": "urn:li:corpuser:jdoe",
323+
"type": "BUSINESS_OWNER"
324+
}
325+
],
326+
"ownerTypes": {},
327+
"lastModified": {
328+
"time": 1643871600000,
329+
"actor": "urn:li:corpuser:ingestion"
330+
}
331+
}
332+
},
333+
"systemMetadata": {
334+
"lastObserved": 1643871600000,
335+
"runId": "test-csv-enricher",
336+
"lastRunId": "no-run-id-provided"
337+
}
338+
},
309339
{
310340
"entityType": "dashboard",
311341
"entityUrn": "urn:li:dashboard:(looker,baz)",

metadata-ingestion/tests/integration/csv-enricher/csv_enricher_test_data.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resource,subresource,glossary_terms,tags,owners,ownership_type,description,domai
44
"urn:li:dataset:(urn:li:dataPlatform:hive,SampleHiveDataset,PROD)",field_bar,,[urn:li:tag:Legacy],,,field_bar?
55
"urn:li:container:DATABASE",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,container description,urn:li:domain:Engineering
66
"urn:li:chart:(looker,baz1)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
7-
"urn:li:dashboard:(looker,baz)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
7+
"urn:li:dashboard:(looker,baz)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],BUSINESS_OWNER,new description,urn:li:domain:Engineering
88
"urn:li:mlFeature:(test_feature_table_all_feature_dtypes,test_BOOL_LIST_feature)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
99
"urn:li:mlFeatureTable:(urn:li:dataPlatform:feast,user_features)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
1010
"urn:li:mlPrimaryKey:(test_feature_table_all_feature_dtypes,dummy_entity_1)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
@@ -13,3 +13,4 @@ resource,subresource,glossary_terms,tags,owners,ownership_type,description,domai
1313
"urn:li:dataJob:(urn:li:dataFlow:(airflow,dag_abc,PROD),task_123)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
1414
"urn:li:dataFlow:(airflow,dag_abc,PROD)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
1515
"urn:li:notebook:(querybook,1234)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering
16+
"urn:li:dashboard:(looker,baz)",,[urn:li:glossaryTerm:CustomerAccount],[urn:li:tag:Legacy],[urn:li:corpuser:datahub|urn:li:corpuser:jdoe],TECHNICAL_OWNER,new description,urn:li:domain:Engineering

0 commit comments

Comments
 (0)