Skip to content

Commit

Permalink
fix(ingest/csv): add support multiple ownership type for the same dat…
Browse files Browse the repository at this point in the history
  • Loading branch information
dushayntAW authored Apr 15, 2024
1 parent f860f79 commit 20e2cc7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
19 changes: 13 additions & 6 deletions metadata-ingestion/src/datahub/ingestion/source/csv_enricher.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,19 @@ def get_resource_owners_work_unit(
# If we want to overwrite or there are no existing tags, create a new GlobalTags object
current_ownership = OwnershipClass(owners, lastModified=get_audit_stamp())
else:
current_owner_urns: Set[str] = set(
[owner.owner for owner in current_ownership.owners]
)
owners_filtered: List[OwnerClass] = [
owner for owner in owners if owner.owner not in current_owner_urns
]
owners_filtered: List[OwnerClass] = []
for owner in owners:
owner_exists = False
for current_owner in current_ownership.owners:
if (
owner.owner == current_owner.owner
and owner.type == current_owner.type
):
owner_exists = True
break
if not owner_exists:
owners_filtered.append(owner)

# If there are no new owners to add, we don't need to emit a work unit.
if len(owners_filtered) <= 0:
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,36 @@
"runId": "test-csv-enricher"
}
},
{
"entityType": "dashboard",
"entityUrn": "urn:li:dashboard:(looker,baz)",
"changeType": "UPSERT",
"aspectName": "ownership",
"aspect": {
"json": {
"owners": [
{
"owner": "urn:li:corpuser:datahub",
"type": "BUSINESS_OWNER"
},
{
"owner": "urn:li:corpuser:jdoe",
"type": "BUSINESS_OWNER"
}
],
"ownerTypes": {},
"lastModified": {
"time": 1643871600000,
"actor": "urn:li:corpuser:ingestion"
}
}
},
"systemMetadata": {
"lastObserved": 1643871600000,
"runId": "test-csv-enricher",
"lastRunId": "no-run-id-provided"
}
},
{
"entityType": "dashboard",
"entityUrn": "urn:li:dashboard:(looker,baz)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resource,subresource,glossary_terms,tags,owners,ownership_type,description,domai
"urn:li:dataset:(urn:li:dataPlatform:hive,SampleHiveDataset,PROD)",field_bar,,[urn:li:tag:Legacy],,,field_bar?
"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
"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
"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
"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
"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
"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
"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
Expand All @@ -13,3 +13,4 @@ resource,subresource,glossary_terms,tags,owners,ownership_type,description,domai
"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
"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
"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
"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 comments on commit 20e2cc7

Please sign in to comment.