3

I am trying to name relationship link (by using attributeDefs) between two different types. The relationship is now registered in Atlas and definition fetch results as below:

{
"category": "RELATIONSHIP",
"guid": "9b1059c3-8707-46db-ae3c-e8d1b4ef6333",
"createdBy": "admin",
"updatedBy": "admin",
"createTime": 1625233869809,
"updateTime": 1625496519772,
"version": 6,
"name": "field_assignment",
"description": "someDescription.",
"typeVersion": "1.0",
"attributeDefs": [
    {
        "name": "LinkInformation",
        "typeName": "string",
        "isOptional": true,
        "cardinality": "SINGLE",
        "valuesMinCount": 0,
        "valuesMaxCount": 1,
        "isUnique": false,
        "isIndexable": false,
        "includeInNotification": false,
        "searchWeight": -1
    }
],
"relationshipCategory": "ASSOCIATION",
"propagateTags": "NONE",
"endDef1": {
    "type": "custom_dataset",
    "name": "fields",
    "isContainer": false,
    "cardinality": "SET",
    "isLegacyAttribute": false
},
"endDef2": {
    "type": "custom_field",
    "name": "datasets",
    "isContainer": false,
    "cardinality": "SET",
    "isLegacyAttribute": false
}

}

Now, I am trying to create a relationship between two types while defining an Entity for either type like

{
"entities": [
    {
        "typeName": "custom_field",
        "createdBy": "admin",
        "guid": -1000,
        "attributes": {
            "name": "type",
            "datasets": [
                {
                    "guid": "-200",
                    "typeName": "custom_dataset"
                }
            ]
        },
        "classifications": [],
        
    }
],
"referredEntities": {
    "-200": {
        "guid": "-200",
        "typeName": "custome_dataset",
        "relationshipAttributes" : {"LinkInformation": "key"},
        
        "attributes": {
            "qualifiedName": "test"
        }
    }
}

}

Through, while executing this, I don't see any error and entities are created but LinkInformation is null by simply doing a search by GUID for entities.

...
"relationshipAttributes": {
                    "typeName": "field_assignment",
                    "attributes": {
                        "LinkInformation": null
                    }
                }
...

I am not able to find a good documentation anywhere for this. Can anyone help?

s_mj
  • 530
  • 11
  • 28

1 Answers1

0

Atlas relationship between existing entities can be created either using entity GUIDs or uniqueAttributes in end1 and end2 which can be qualifiedName or any other unique attribute .

Please do note that top level typeName is the relationship def typeName while typeName inside end1 and end2 is entity typeName.

In case of relationship between hive_table and hive_db the relationship def typeName is: hive_table_db So, if you want to create a relationship between hive_table and hive_db, the request would be:

POST: /api/atlas/v2/relationship
    {
    "typeName": "hive_table_db",
    "end1": {
        "typeName": "hive_table",
        "uniqueAttributes": {
            "qualifiedName": "db.table@cluster"
        }
    },
    "end2": {
        "typeName": "hive_db",
        "uniqueAttributes": {
            "qualifiedName": "db@cluster"
        }
    }
}

For predefined Atlas types you can find the relationship typeName from its definition inside relationshipAttributeDefs field GET: /api/atlas/v2/types/typedef/name/hive_db

Which gives the following response:

{
"category": "ENTITY",
"guid": "9b1059c3-8707-46db-ae3c-e8d1b4ef6333",
"createdBy": "root",
"updatedBy": "root",
"createTime": 1548175553859,
"updateTime": 1548175822249,
"version": 2,
"name": "hive_db",
"description": "hive_db",
"typeVersion": "1.2",
"serviceType": "hive",
"attributeDefs": [
    {
        "name": "clusterName",
        "typeName": "string",
        "isOptional": false,
        "cardinality": "SINGLE",
        "valuesMinCount": 1,
        "valuesMaxCount": 1,
        "isUnique": false,
        "isIndexable": true,
        "includeInNotification": true,
        "searchWeight": -1
    },
    {
        "name": "location",
        "typeName": "string",
        "isOptional": true,
        "cardinality": "SINGLE",
        "valuesMinCount": 0,
        "valuesMaxCount": 1,
        "isUnique": false,
        "isIndexable": false,
        "includeInNotification": false,
        "searchWeight": -1
    },
    {
        "name": "parameters",
        "typeName": "map<string,string>",
        "isOptional": true,
        "cardinality": "SINGLE",
        "valuesMinCount": 0,
        "valuesMaxCount": 1,
        "isUnique": false,
        "isIndexable": false,
        "includeInNotification": false,
        "searchWeight": -1
    },
    {
        "name": "ownerType",
        "typeName": "hive_principal_type",
        "isOptional": true,
        "cardinality": "SINGLE",
        "valuesMinCount": 0,
        "valuesMaxCount": 1,
        "isUnique": false,
        "isIndexable": false,
        "includeInNotification": false,
        "searchWeight": -1
    }
],
"superTypes": [
    "Asset"
],
"subTypes": [],
"relationshipAttributeDefs": [
    {
        "name": "tables",
        "typeName": "array<hive_table>",
        "isOptional": true,
        "cardinality": "SET",
        "valuesMinCount": -1,
        "valuesMaxCount": -1,
        "isUnique": false,
        "isIndexable": false,
        "includeInNotification": false,
        "searchWeight": -1,
        "constraints": [
            {
                "type": "ownedRef"
            }
        ],
        "relationshipTypeName": "hive_table_db",
        "isLegacyAttribute": false
    },
    {
        "name": "ddlQueries",
        "typeName": "array<hive_db_ddl>",
        "isOptional": true,
        "cardinality": "SET",
        "valuesMinCount": -1,
        "valuesMaxCount": -1,
        "isUnique": false,
        "isIndexable": false,
        "includeInNotification": false,
        "searchWeight": -1,
        "constraints": [
            {
                "type": "ownedRef"
            }
        ],
        "relationshipTypeName": "hive_db_ddl_queries",
        "isLegacyAttribute": false
    },
    {
        "name": "meanings",
        "typeName": "array<AtlasGlossaryTerm>",
        "isOptional": true,
        "cardinality": "SET",
        "valuesMinCount": -1,
        "valuesMaxCount": -1,
        "isUnique": false,
        "isIndexable": false,
        "includeInNotification": false,
        "searchWeight": -1,
        "relationshipTypeName": "AtlasGlossarySemanticAssignment",
        "isLegacyAttribute": false
    }
]

}

Further, you need to make sure the typeName in end1 and end2 is as per the relationship def, which you can check in type definition:

GET: /api/atlas/v2/types/typedef/name/hive_table_db
{
    "category": "RELATIONSHIP",
    "guid": "9b1059c3-8707-46db-ae3c-e8d1b4ef6333",
    "createdBy": "root",
    "updatedBy": "root",
    "createTime": 1548175553894,
    "updateTime": 1548175553894,
    "version": 1,
    "name": "hive_table_db",
    "description": "hive_table_db",
    "typeVersion": "1.0",
    "serviceType": "hive",
    "attributeDefs": [],
    "relationshipCategory": "COMPOSITION",
    "propagateTags": "NONE",
    "endDef1": {
        "type": "hive_table",
        "name": "db",
        "isContainer": false,
        "cardinality": "SINGLE",
        "isLegacyAttribute": true
    },
    "endDef2": {
        "type": "hive_db",
        "name": "tables",
        "isContainer": true,
        "cardinality": "SET",
        "isLegacyAttribute": false

} }

Kumar Pankaj Dubey
  • 1,541
  • 3
  • 17
  • 17
  • I am not looking to use TypeName but rather create a new attribute that holds link information – s_mj Sep 14 '21 at 07:56