3

我试图命名两种不同类型之间的关系链接(通过使用attributeDefs)。该关系现已在 Atlas 中注册,定义获取结果如下:

{
"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
}

}

现在,我正在尝试在两种类型之间创建关系,同时为任何一种类型定义实体,例如

{
"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"
        }
    }
}

}

通过,在执行此操作时,我没有看到任何错误并且实体已创建,但LinkInformation通过简单地搜索GUID实体为空。

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

我无法在任何地方找到一个好的文档。任何人都可以帮忙吗?

4

1 回答 1

0

现有实体之间的图集关系可以使用实体 GUID 或 end1 和 end2 中的 uniqueAttributes 创建,可以是qualifiedName 或任何其他唯一属性。

请注意,顶级 typeName 是关系 def typeName,而 end1 和 end2 中的 typeName 是实体 typeName。

在 hive_table 和 hive_db 之间的关系的情况下,关系 def typeName 是:hive_table_db 因此,如果要在 hive_table 和 hive_db 之间创建关系,请求将是:

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"
        }
    }
}

对于预定义的 Atlas 类型,您可以在 relationshipAttributeDefs 字段 GET 中找到关系 typeName:/api/atlas/v2/types/typedef/name/hive_db

这给出了以下响应:

{
"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
    }
]

}

此外,您需要确保 end1 和 end2 中的 typeName 符合关系 def,您可以在类型定义中检查:

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

} }

于 2021-09-08T09:10:24.310 回答