Troubleshooting deletion of Glossary Terms in Datahub using Python and GraphQL

Original Slack Thread

Hi team,
Please tell me how to delete all(or one) Glossary Terms on the Glossary tab with Python or GraphQL (code example).

I ran the code below, and got “{‘batchRemoveTerms’: True}” returned.
However, it was not actually deleted from the Glossary tab.
I need your help.

import time

gms_endpoint = "#######"
graph = DataHubGraph(DatahubClientConfig(server=gms_endpoint))

start = time.time()

for i in range(len(df)):
    term_urn = "urn:li:glossaryTerm:" + df['공통표준용어명'][i]
    mutation = f"""
    mutation batchRemoveTerms {{
        batchRemoveTerms(
          input: {{
            termUrns: ["{term_urn}"],
            resources: []
          }}
        )
    }}
    """
    result = graph.execute_graphql(query=mutation)
    print(result)
    
end = time.time() 
print(f"{end - start: .2f} sec")```![attachment](https://files.slack.com/files-pri/TUMKD5EGJ-F05Q8PG8ES0/image.png?t=xoxe-973659184562-6705490291811-6708051934148-dd1595bd5f63266bc09e6166373c7a3c)

That’s weird - <@U04N9PYJBEW> Could you look into this?

Hmm, I’m not sure. Can you double check you’re pointed at the right gms endpoint and that the urns you’re specifying exactly match the glossary terms you’re checking in the UI? Beyond that, <@U05CJD391ND> are you familiar with any bugs on this mutation?

<@U05NNLQG9BM> I believe you need to specify a resource urn in the resources array. In other words, this gql endpoint is about batch removing glossary terms from entities, but not deleting the glossary term from your datahub instance globally.

We have this doc that explains more about ways to remove metadata from datahub https://datahubproject.io/docs/how/delete-metadata/. Just make sure you’re careful to not remove data you want to keep.

> As of datahub v0.10.2.3, hard deleting tags, glossary terms, users, and groups will also remove references to those entities across the metadata graph.