Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to delete/update type in Atlas that has existing entities?

How to delete/update type in Atlas that has existing entities?

New Contributor

Hi everyone,

I am just recently working with Atlas and already stuck with something.


I created a custom typedef called 'Table' with this structure:

{
        "superTypes" : [],
        "category" : "ENTITY",
        "name" : "Table",
        "description" : "a type definition for an existing table from BigQuery",
        "typeVersion" : "1.0",
        "attributeDefs" :[
            {
                "name" : "dataset_name",
                "typeName" : "string",
                "isOptional" : False,
                "cardinality" : "SINGLE",
                "valuesMinCount" : 1,
                "valuesMaxCount" : 1,
                "isUnique" : False,
                "isIndexable" : True
            }
            ,{
                "name" : "schema",
                "typeName" : "array<Column>",
                "isOptional" : True,
                "cardinality" : "SINGLE",
                "valuesMinCount" : 1,
                "valuesMaxCount" : 1,
                "isUnique" : False,
                "isIndexable" : True
                }
        ]
}

And then I have created some entities with the typeName 'Table'.

The problem is that I forgot one required attribute inside the 'Table' typedef and want to add it.


The first solution I thought of was deleting the 'Table' typedef and creating a new one. But unfortunately it returned with this response:

{"errorCode":"ATLAS-409-00-002","errorMessage":"Given type Table has references"}

I assumed that this is because I have entities that refers to my 'Table' type. I tried deleting all the 'Table' entities with the Atlas API and tried deleting the 'Table' typedef again, but it still returned the same error code shown above. I found on some other forum that I need to hard delete the entities, but the API only provides soft delete. So how do I hard delete?


The second solution was to use the update endpoint to insert the new attribute, but it did not work and returned:

{"errorCode":"ATLAS-400-00-00C","errorMessage":"Table.name : can not add mandatory attribute"}

I assume that this is because the attribute I tried to add is set to "isOptional: False" and there are existing entities.


So now I'm stuck with no idea how to handle this. For the moment, I'll create a new type and continue my work but hopefully someone can help me solve this. I appreciate anyone that can provide me with the best way to handle this. Thank you!


(P.S. If you need it, the attribute that I'm trying to add is this:

{
    "name" : "name",
    "typeName" : "string",
    "isOptional" : False,
    "cardinality" : "SINGLE",
    "valuesMinCount" : 1,
    "valuesMaxCount" : 1,
    "isUnique" : False,
    "isIndexable" : True
}

)

(P.P.S. I am using Python to access the API)

Don't have an account?
Coming from Hortonworks? Activate your account here