Skip to content

Commit fd80ca5

Browse files
committed
Preserve existing siblings
1 parent 62f2789 commit fd80ca5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

metadata-ingestion/src/datahub/cli/specific/dataset_cli.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,21 @@ def add_sibling(urn: str, sibling_urns: Tuple[str]) -> None:
9393
def _emit_sibling(
9494
graph: DataHubGraph, primary_urn: str, urn: str, all_urns: Set[str]
9595
) -> None:
96-
siblings = []
96+
siblings = _get_existing_siblings(urn, graph)
9797
for sibling_urn in all_urns:
9898
if sibling_urn != urn:
99-
siblings.append(sibling_urn)
99+
siblings.add(sibling_urn)
100100
graph.emit(
101101
MetadataChangeProposalWrapper(
102102
entityUrn=urn,
103103
aspect=Siblings(primary=primary_urn == urn, siblings=sorted(siblings)),
104104
)
105105
)
106+
107+
108+
def _get_existing_siblings(graph: DataHubGraph, urn: str) -> Set[str]:
109+
existing = graph.get_aspect(urn, Siblings)
110+
if existing:
111+
return set(existing.siblings)
112+
else:
113+
return set()

0 commit comments

Comments
 (0)