Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to remove an aspect type from entry in Dataplex Catalog [Python SDK]

Hello, I'm migrating some python workloads from Data Catalog to Dataplex catalog and I'm struggling with automating the aspect type deletion. Via the google-cloud-dataplex python SDK I'm able to add new aspect types to entries or schemas in entries but I could not find a way to remove them.

Let's say I have an aspect type added to a field in a table schema, I want to remove it from there in a programmatic fashion, all I could find is the update_entry method that I used to add aspects in the first place via updating the underlying protobuf.

When via the UI I try to remove an aspect, I can see in the logs that the API request has an additional parameter call delete_missing_aspects, but there is nothing like data available in any of the dataplex classes and methods, I'm assuming this is a flag to hint the deletion to the internal engine.

It seems that the way to do it is by reconstructing the entry and trying to remove the specific aspect type and then trying to update_entry passing the entry without the aspect but I could not make it work.

Anyone has code snippet of how to achieve this?

The documentation I've been following:  https://cloud.google.com/dataplex/docs/reference/rpc/google.cloud.dataplex.v1#google.cloud.dataplex.... https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-dataplex/samples/g...

thanks!


Solved Solved
0 2 157
1 ACCEPTED SOLUTION

Here is an example below on how to delete overview aspect from an entry. Also take a look at the documentation of the endpoint talking about the parameter deleteMissingAspects. Please take a look:

# Create a client
client = dataplex_v1.CatalogServiceAsyncClient()

request = dataplex_v1.UpdateEntryRequest(
entry=dataplex_v1.Entry(
  name="projects/<<your-project-id>>/locations/<<your-location>>/entryGroups/<<your-entryGroup>>/entries/<<your-entry-id>>>",
  aspects={}
  aspectKeys=["dataplex-types.global.overview"]
  deleteMissingAspects=True
),
update_mask=field_mask_pb2.FieldMask(
  paths=["aspects"]
),
)

# Make the request
response = await client.update_entry(request=request)


print(response)
 

 

View solution in original post

2 REPLIES 2

Here is an example below on how to delete overview aspect from an entry. Also take a look at the documentation of the endpoint talking about the parameter deleteMissingAspects. Please take a look:

# Create a client
client = dataplex_v1.CatalogServiceAsyncClient()

request = dataplex_v1.UpdateEntryRequest(
entry=dataplex_v1.Entry(
  name="projects/<<your-project-id>>/locations/<<your-location>>/entryGroups/<<your-entryGroup>>/entries/<<your-entry-id>>>",
  aspects={}
  aspectKeys=["dataplex-types.global.overview"]
  deleteMissingAspects=True
),
update_mask=field_mask_pb2.FieldMask(
  paths=["aspects"]
),
)

# Make the request
response = await client.update_entry(request=request)


print(response)
 

 

Thanks @Leo_ng ! Eventually I landed in that class' page, much appreciated your response!