fix(cli): add-sibling preserve existing siblings (#9907)

This commit is contained in:
Steven Ayers 2024-02-23 19:30:17 +00:00 committed by GitHub
parent 639dd146d7
commit def4b24bb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,13 +93,21 @@ def add_sibling(urn: str, sibling_urns: Tuple[str]) -> None:
def _emit_sibling(
graph: DataHubGraph, primary_urn: str, urn: str, all_urns: Set[str]
) -> None:
siblings = []
siblings = _get_existing_siblings(graph, urn)
for sibling_urn in all_urns:
if sibling_urn != urn:
siblings.append(sibling_urn)
siblings.add(sibling_urn)
graph.emit(
MetadataChangeProposalWrapper(
entityUrn=urn,
aspect=Siblings(primary=primary_urn == urn, siblings=sorted(siblings)),
)
)
def _get_existing_siblings(graph: DataHubGraph, urn: str) -> Set[str]:
existing = graph.get_aspect(urn, Siblings)
if existing:
return set(existing.siblings)
else:
return set()