Deleting Every URN in a Container Using DataHub CLI

Original Slack Thread

<@U06TM7M40RK> How do I delete every urn in a container?

To delete every URN in a container using DataHub, you can use the DataHub CLI with the --recursive flag. This will ensure that all entities contained within the specified container are deleted. Here is a step-by-step guide:

  1. Identify the Container URN: You need to find the URN of the container. This can be done by navigating to the relevant container in the DataHub UI and copying the URN.

  2. Use the datahub delete Command: Use the datahub delete command with the --urn option to specify the container URN and the --recursive flag to delete all contained entities.

  3. Perform the Delete: By default, the delete command performs a soft delete. You can add the --hard flag to perform a hard delete if needed.

Here is an example command:

datahub delete --urn "urn:li:container:<container_urn>" --recursive

If you want to perform a hard delete, use the following command:

datahub delete --urn "urn:li:container:<container_urn>" --recursive --hard

Important Considerations:

  • Dry Run: Use the --dry-run flag to see what entities will be deleted before actually performing the delete operation.
  • Force: The --force flag can be used to skip confirmation prompts.

Example with Dry Run and Force:

datahub delete --urn "urn:li:container:<container_urn>" --recursive --dry-run --force

Would you like more detailed information on how to perform this operation safely, or do you have any specific concerns about the deletion process?

Sources: