feat(cli): reject missing urns in datahub get (#11313)

This commit is contained in:
Harshal Sheth 2024-09-06 15:32:25 -07:00 committed by GitHub
parent 0ce9e946a6
commit 607ad5e1bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 8 deletions

View File

@ -31,6 +31,8 @@ This file documents any backwards-incompatible changes in DataHub and assists pe
```
Re-running with stateful ingestion should automatically clear up the entities with old URNS and add entities with new URNs, therefore not duplicating the containers or jobs.
- #11313 - `datahub get` will no longer return a key aspect for entities that don't exist.
### Potential Downtime
### Deprecations

View File

@ -48,16 +48,28 @@ def urn(ctx: Any, urn: Optional[str], aspect: List[str], details: bool) -> None:
client = get_default_graph()
if aspect:
# If aspects are specified, we need to do the existence check first.
if not client.exists(urn):
raise click.ClickException(f"urn {urn} not found")
aspect_data = get_aspects_for_entity(
session=client._session,
gms_host=client.config.server,
entity_urn=urn,
aspects=aspect,
typed=False,
details=details,
)
if not aspect:
# If no aspects are specified and we only get a key aspect back, yield an error instead.
if len(aspect_data) == 1 and "key" in next(iter(aspect_data)).lower():
raise click.ClickException(f"urn {urn} not found")
click.echo(
json.dumps(
get_aspects_for_entity(
session=client._session,
gms_host=client.config.server,
entity_urn=urn,
aspects=aspect,
typed=False,
details=details,
),
aspect_data,
sort_keys=True,
indent=2,
)