Area: Ingestion Issues
Sub-Area: Iceberg REST Catalog / Entity Lifecycle Management
Applies to: OSS + Cloud
Issue
You use the DataHub Iceberg Catalog (DataHub as your Iceberg REST catalog) with Spark, StarRocks or another engine. A DROP TABLE fails partway with a server error. After that:
- Reads and writes on the table fail because the catalog reports that the table does not exist.
-
CREATE TABLEwith the same name can also fail because the catalog reports that the table already exists. - The old dataset page in DataHub still opens by URN and shows this banner:
This entity is not discoverable via search or lineage graph. Contact your DataHub admin for more information.
You Might Be Asking
- Why does my Iceberg table show a "not discoverable" banner in DataHub when I can still open it by URN?
- Why does Spark say the table is not found, but
CREATE TABLEsays it already exists? - How did the table end up soft-deleted when I never deleted it in the DataHub UI?
- Is it safe to hard delete the soft-deleted dataset? Does that delete my data in S3?
- Do I need to run ingestion after I recreate the table?
Cause
In the DataHub Iceberg Catalog, each table is stored as two DataHub entities (see the Conceptual Mapping in DataHub Iceberg Catalog):
- A
platformResourcethat holds the table name:urn:li:platformResource:iceberg.<warehouse>.<namespace>.<table>. It points to the dataset. - A
datasetthat holds the table metadata. Its name is the warehouse plus a random UUID, not the table name:urn:li:dataset:(urn:li:dataPlatform:iceberg,<warehouse>.<uuid>,<ENV>). ItsicebergCatalogInfoaspect holds the location of the table's current metadata file.
A DROP TABLE (or DROP VIEW) through the catalog runs in two steps:
- It soft-deletes both entities (sets
status.removedtotrue). - It hard-deletes the platform resource, then hard-deletes the dataset.
If the drop fails after step 1, one or both entities stay soft-deleted. The catalog skips any entity whose status.removed is true, so it treats the table as missing and engines report "table not found". The DataHub UI shows the banner above for any entity with status.removed set to true.
If the soft-deleted platform resource is still there, it also blocks a new CREATE TABLE with the same name. Table creation must create a new platform resource for that name, and DataHub rejects the create because an entity with that URN already exists.
The Iceberg catalog's own drop causes this state. You don't need a manual delete, tag change or other API call for it to happen.
Solution
1. Find the URNs
You need two URNs:
- The platform resource:
urn:li:platformResource:iceberg.<warehouse>.<namespace>.<table>. Use the warehouse name fromdatahub iceberg listand the namespace levels joined with dots. - The dataset: read it from the platform resource, or copy it from the URL of the dataset page that shows the banner. Don't build it from the table name. The dataset name is
<warehouse>.<uuid>.
This script uses the DataHub Python SDK (acryl-datahub) to check the platform resource and print the dataset URN and the table's current metadata file:
from datahub.ingestion.graph.client import DatahubClientConfig, DataHubGraph
from datahub.metadata.schema_classes import (
IcebergCatalogInfoClass,
PlatformResourceInfoClass,
StatusClass,
)
graph = DataHubGraph(
DatahubClientConfig(server="<your-datahub-gms-url>", token="<your-api-token>")
)
resource_urn = "urn:li:platformResource:iceberg.<warehouse>.<namespace>.<table>"
resource_info = graph.get_aspect(resource_urn, PlatformResourceInfoClass)
resource_status = graph.get_aspect(resource_urn, StatusClass)
print("Resource found:", resource_info is not None)
print("Resource removed:", resource_status.removed if resource_status else None)
if resource_info:
dataset_urn = resource_info.primaryKey
print("Dataset URN:", dataset_urn)
catalog_info = graph.get_aspect(dataset_urn, IcebergCatalogInfoClass)
print("Metadata file:", catalog_info.metadataPointer if catalog_info else None)
Read the output:
-
Resource removed: True: the drop stopped before it hard-deleted the platform resource. Clean up both entities in step 2. -
Resource found: False: the platform resource is already gone. The name is free andCREATE TABLEworks. Only the dataset is left behind. Use the dataset URN from the page URL in step 2. -
Resource removed: False: the table is not in this state. Stop here and don't delete anything.
If you want the old table back instead of a new empty one, save the Metadata file path now. The hard delete in step 2 removes it from DataHub.
2. Hard delete the leftover entities
Hard delete the platform resource first (if it still exists), then the dataset. The CLI asks you to confirm each hard delete:
datahub delete --urn "urn:li:platformResource:iceberg.<warehouse>.<namespace>.<table>" --hard
datahub delete --urn "urn:li:dataset:(urn:li:dataPlatform:iceberg,<warehouse>.<uuid>,<ENV>)" --hard
You can also hard delete from the SDK with graph.hard_delete_entity(urn="<urn>").
A hard delete removes every aspect of that entity from DataHub and can't be undone. On the old dataset that includes tags, glossary terms, documentation, ownership and the icebergCatalogInfo aspect. DataHub doesn't delete any files in your S3 data root when you drop a table or hard delete these entities. See Removing Metadata from DataHub for soft delete and hard delete.
3. Recreate or re-register the table
- To start fresh, run
CREATE TABLEthrough the DataHub Iceberg Catalog. The catalog creates the platform resource and a new dataset with a new UUID URN right away. You don't need an ingestion run. - To bring back the old table, register the metadata file you saved in step 1 with
system.register_table. See Migrating from Other Iceberg Catalogs.
Either way, the table gets a new dataset URN. Tags, terms, documentation and ownership from the old dataset don't carry over, so apply them again.