KnowForge/Apache Atlas 2.5.0/ 返回书籍
Import/Export

Import Entity Transforms

qianmoQqianmoQ· 更新于 2026-09-21· 阅读 10 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

(New) Entity Transforms Framework

Background

During Import Process, entity transforms are required to make changes to the entity before it gets committed to the database. These modifications are necessary to make the entity conform to the environment it is going to reside. The Import Process provided a mechanism to do that.

Transformation Framework

A transformation framework allows a mechanism to selectively transform an entity or specific attributes of that entity.

To achieve this, the framework provides:

  • Way to set a condition that needs to be satisfied for a transformation to be applied.
  • Action to be taken on the entity once the condition is met.

The existing transformation frameworks allowed this to happen.

Reason for New Transformation Framework

While the existing framework provided the basic benefits of the transformation framework, it did not have support for some commonly used Atlas types. Which meant that users of this framework would have to meticulously define transformations for every type they are working with. This can be tedious and potentially error-prone. The new framework addresses this problem by providing built-in transformations for some commonly used types. It can also be extended to accommodate new types.

Approach

The approach used by the new transformation framework creates a transformation by:

  • Specifying a condition.
  • Specifying action(s) to be taken if the condition is met.
Conditions

Following are built-in conditions.

Condition TypesDescription
ENTITY_ALLAny/every entity
ENTITY_TOP_LEVELEntity that is the top-level entity. This is also the entity present specified in AtlasExportRequest.
EQUALSEntity attribute equals to the one specified in the condition.
EQUALS_IGNORE_CASEEntity attribute equals to the one specified in the condition ignoring case.
STARTS_WITHEntity attribute starts with.
STARTS_WITH_IGNORE_CASEEntity attribute starts with ignoring case.
HAS_VALUEEntity attribute has value.
Actions
Action Type*Description**
ADD_CLASSIFICATIONAdd classification
REPLACE_PREFIXReplace value starting with another value.
TO_LOWERConvert a value of an attribute to lower case.
SETSet the value of an attribute
CLEARClear value of an attribute

Built-in Transforms

Add Classification

During import, hivedb entity whose _qualifiedName is stocks@cl1 will get the classification clSrcImported.

{
    "conditions": {
        "hive_db.qualifiedName": "stocks@cl1"
    },
    "action": {
        "__entity": "ADD_CLASSIFICATION: clSrcImported"
    }
}

Every imported entity will get the classification by simply changing the condition. The __entity is a special condition which matches entity.

{
    "conditions": {
        "__entity": ""
    },
    "action": {
        "__entity": "ADD_CLASSIFICATION: clSrcImported"
    }
}

To add the classification to only the top-level entity (an entity that is used as a starting point for an export), use:

{
    "conditions": {
        "__entity": "topLevel:"
    },
    "action": {
        "__entity": "ADD_CLASSIFICATION: clSrcImported"
    }
}
Replace Prefix

This action works on string values. The first parameter is the prefix that is searched for a match, once matched, it is replaced with the provided replacement string.

The sample below searches for /aa/bb/, once found replaces it with /xx/yy/.

{
    "conditions": {
        "hdfs_path.clusterName": "EQUALS: CL1"
    },
    "action": {
        "hdfs_path.path": "REPLACE_PREFIX: = :/aa/bb/=/xx/yy/"
    }
}
To Lower

Entity whose hdfs_path.clusterName is CL1 will get its path attribute converted to lower case.

{
    "conditions": {
        "hdfs_path.clusterName": "EQUALS: CL1"
    },
    "action": {
        "hdfs_path.path": "TO_LOWER:"
    }
}
Clear

Entity whose hdfspath.clusterName has value set, will get its _replicatedTo attribute value cleared.

{
    "conditions": {
        "hdfs_path.clusterName": "HAS_VALUE:"
    },
    "action": {
        "hdfs_path.replicatedTo": "CLEAR:"
    }
}

Additional Examples

Please look at these tests for examples using Java classes.

评论

登录后参与评论

正在加载评论…