Area: Ingestion Issues
Sub-Area: Snowflake Ingestion / URN Case Handling
Applies to: OSS + Cloud
Issue
You ingested Snowflake with convert_urns_to_lowercase: false. Then you changed it to true (or removed the line, since true is the default) and ran ingestion again. Now each Snowflake table, view, database and schema shows up twice in DataHub. One copy has an uppercase URN, the other a lowercase URN. Stateful ingestion is on, but it did not remove the old uppercase copies.
The run that changed the setting reports this failure:
Skipping stateful ingestion / stale entity removal
Entity difference exceeds fail_safe_threshold; skipping stale entity removal. To update, set stateful_ingestion.fail_safe_threshold in your recipe.
You Might Be Asking
- Why didn't stateful ingestion soft delete the old uppercase URNs?
- How do I clean up the uppercase Snowflake URNs?
- Does changing
convert_urns_to_lowercaseafter ingestion create duplicate assets? - Why do some Snowflake tables show a lowercase name and no database or schema container?
Cause
convert_urns_to_lowercase decides the case of the database, schema and table names in every Snowflake dataset URN. It also goes into the key of each database and schema container. For Snowflake it defaults to true. Only a recipe that sets it to false keeps Snowflake's uppercase names in the URNs.
When you change the setting, every Snowflake dataset and container gets a new URN. DataHub treats the old and new URNs as different assets. The display names come from Snowflake in both cases, so the two copies look the same in the UI.
Stateful ingestion compares the URNs of this run with the URNs stored from the last run. It soft deletes the old URNs that this run did not ingest. Two checks stop that cleanup here:
- Fail-safe. If more than
fail_safe_thresholdpercent of the stored URNs are missing from this run, the run soft deletes nothing and reports the failure above. The default is 75. A full re-key changes close to 100 percent of the URNs, so it always trips the fail-safe. The old URNs stay in the stored state. - Run failures. If the source reports a failure, for example from missing Snowflake permissions, the run skips stale entity removal and reports "The soft-deletion of stale entities will be skipped because the source reported a failure."
Solution
Before you start, set the value you want to keep in the recipe and do not change it again:
source:
type: snowflake
config:
convert_urns_to_lowercase: true
# ... other config options
Documentation, tags, owners and glossary terms that you added in the UI stay on the old uppercase assets. They do not move to the new lowercase assets. Copy what you need before you soft delete the old ones.
Option 1 (recommended): Let stateful ingestion remove the old URNs
Use this when the uppercase assets came from earlier runs of the same recipe with stateful ingestion on. The fail-safe failure above shows that the old URNs are in the stored state.
-
Fix any Snowflake permission errors first. A run that reports a failure skips the cleanup.
-
Keep the same top-level
pipeline_nameand the rest of the recipe unchanged. Setfail_safe_thresholdto 100 for one run. Thestateful_ingestionblock goes undersource.config:pipeline_name: snowflake_ingestion # keep your existing name source: type: snowflake config: convert_urns_to_lowercase: true # ... other config options stateful_ingestion: enabled: true fail_safe_threshold: 100 # remove after this run -
Run the ingestion once. It soft deletes every stored URN that it did not ingest: the old uppercase datasets and the old database and schema containers.
-
Remove
fail_safe_threshold: 100. A value of 100 turns the fail-safe off for every run.
To list the URNs in the stored state, run datahub state inspect --pipeline-name <your_pipeline_name> --platform snowflake.
The settings are described in Stale Entity Removal.
Option 2: Soft delete only the uppercase datasets with the CLI
Use this when the uppercase assets are not in the stored state, for example because they came from a different recipe or from runs without stateful ingestion.
-
Install the DataHub CLI and connect it to your DataHub (
datahub init, or setDATAHUB_GMS_URLandDATAHUB_GMS_TOKEN):pip install acryl-datahub -
Run this script. It only reads. It writes the URNs of Snowflake datasets whose name has capital letters to
uppercase_urns.txt. It checks the name part of the URN only, because every dataset URN contains capital letters elsewhere (dataPlatform,PROD):from datahub.ingestion.graph.client import get_default_graph from datahub.metadata.urns import DatasetUrn graph = get_default_graph() with open("uppercase_urns.txt", "w") as f: for urn in graph.get_urns_by_filter(entity_types=["dataset"], platform="snowflake"): name = DatasetUrn.from_string(urn).name if name != name.lower(): f.write(urn + "\n")If your recipe sets a
platform_instancewith capital letters, the name part starts with it. Change the check to skip that prefix. -
Review the list, then do a dry run. It prints the URNs and deletes nothing:
datahub delete --urn-file uppercase_urns.txt --dry-run -
Soft delete them:
datahub delete --urn-file uppercase_urns.txt --soft --force -
The old database and schema containers have hashed URNs and the same display names as the new ones, so the script cannot find them. In the UI, open each old container (it is empty after step 4), use Copy URN, and soft delete it with
datahub delete --urn "<container_urn>" --soft.
Option 3: Soft delete all Snowflake assets and re-ingest
This soft deletes every Snowflake entity in DataHub, including those from other Snowflake recipes. A re-run of a recipe restores only the assets that recipe ingests.
-
Soft delete all Snowflake assets:
datahub delete --platform snowflake --soft --force -
Run each Snowflake recipe once with
ignore_old_state: true, then remove it. Without it, the stored state still holds the old URNs, so the run trips the fail-safe and reports a failure:source: type: snowflake config: convert_urns_to_lowercase: true # ... other config options stateful_ingestion: enabled: true ignore_old_state: true # remove after this runThat run ingests the assets with lowercase URNs, marks them as not deleted, and stores a new state.
To restore soft-deleted assets, use datahub delete undo-by-filter --platform snowflake or datahub delete undo-by-filter --urn "<urn>". See Removing Metadata from DataHub.
Tables with a lowercase name and no container
A Snowflake table can show a lowercase name and no database or schema container. That table was not ingested by the Snowflake recipe. DataHub knows it only from lineage or from another source, such as dbt.
- Check that the recipe's
database_patternandschema_patterninclude the table's database and schema. - Check that the DataHub role has the grants in Snowflake Prerequisites. It needs
usageon the database and its schemas, andreferences(orselect, if you use profiling or classification) on the tables and views. - Re-run the Snowflake ingestion.
Additional Notes
- For the Snowflake source,
convert_urns_to_lowercasedefaults totrue. A recipe that sets it tofalselogs this warning: "Please useconvert_urns_to_lowercase: True, otherwise lineage to other sources may not work correctly." - To see which value an earlier run used, open the ingestion source's Run History tab and check the recipe of that run.
- Soft delete sets the asset's
statusto removed and keeps its metadata. Hard delete removes it from the database. Use soft delete for this cleanup.
Related Documentation
- Snowflake source
- Snowflake Prerequisites
- Stateful Ingestion: Stale Entity Removal
- Removing Metadata from DataHub
Tags: snowflake, ingestion, urns, lowercase, uppercase, stateful-ingestion, soft-delete, convert_urns_to_lowercase, fail_safe_threshold, permissions