|
14 | 14 | SystemMetadataClass,
|
15 | 15 | _Aspect,
|
16 | 16 | )
|
17 |
| -from datahub.utilities.urns.urn import guess_entity_type |
| 17 | +from datahub.utilities.urns.urn import Urn, guess_entity_type |
18 | 18 |
|
19 | 19 | if TYPE_CHECKING:
|
20 | 20 | from datahub.ingestion.api.workunit import MetadataWorkUnit
|
@@ -63,15 +63,19 @@ class MetadataChangeProposalWrapper:
|
63 | 63 |
|
64 | 64 | entityType: str = _ENTITY_TYPE_UNSET
|
65 | 65 | changeType: Union[str, ChangeTypeClass] = ChangeTypeClass.UPSERT
|
66 |
| - entityUrn: Union[None, str] = None |
| 66 | + entityUrn: Union[None, str,] = None |
67 | 67 | entityKeyAspect: Union[None, _Aspect] = None
|
68 | 68 | auditHeader: Union[None, KafkaAuditHeaderClass] = None
|
69 | 69 | aspectName: Union[None, str] = None
|
70 | 70 | aspect: Union[None, _Aspect] = None
|
71 | 71 | systemMetadata: Union[None, SystemMetadataClass] = None
|
72 | 72 |
|
73 | 73 | def __post_init__(self) -> None:
|
74 |
| - if self.entityUrn and self.entityType == _ENTITY_TYPE_UNSET: |
| 74 | + if isinstance(self.entityUrn, Urn): |
| 75 | + if self.entityType == _ENTITY_TYPE_UNSET: |
| 76 | + self.entityType = self.entityUrn.entity_type |
| 77 | + self.entityUrn = str(self.entityUrn) |
| 78 | + elif self.entityUrn and self.entityType == _ENTITY_TYPE_UNSET: |
75 | 79 | self.entityType = guess_entity_type(self.entityUrn)
|
76 | 80 | elif self.entityUrn and self.entityType:
|
77 | 81 | guessed_entity_type = guess_entity_type(self.entityUrn).lower()
|
@@ -104,7 +108,8 @@ def construct_many(
|
104 | 108 | ) -> List["MetadataChangeProposalWrapper"]:
|
105 | 109 | return [cls(entityUrn=entityUrn, aspect=aspect) for aspect in aspects if aspect]
|
106 | 110 |
|
107 |
| - def _make_mcp_without_aspects(self) -> MetadataChangeProposalClass: |
| 111 | + def _make_mcp_without_aspects(self) -> MetadataChangeProposalClass: |
| 112 | + assert self.entityUrn is None or isinstance(self.entityUrn, str) |
108 | 113 | return MetadataChangeProposalClass(
|
109 | 114 | entityType=self.entityType,
|
110 | 115 | entityUrn=self.entityUrn,
|
|
0 commit comments