blob: 938c0f415d8463802e1b356e51ce39a6a645fce0 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{"./src/documents/Import-Export/ImportEntityTransforms.md":function(t,e,a){"use strict";a.r(e),a.d(e,"default",(function(){return l}));var n=a("../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js"),r=(a("../node_modules/react/index.js"),a("../node_modules/@mdx-js/react/dist/esm.js")),i=(a("./theme/styles/styled-colors.js"),a("../node_modules/react-syntax-highlighter/dist/esm/styles/hljs/dark.js")),o=a("../node_modules/react-syntax-highlighter/dist/esm/default-highlight.js"),m=["components"],d={};function l(t){var e=t.components,a=Object(n.a)(t,m);return Object(r.mdx)("wrapper",Object.assign({},d,a,{components:e,mdxType:"MDXLayout"}),Object(r.mdx)("h1",{id:"new-entity-transforms-framework"},"(New) Entity Transforms Framework"),Object(r.mdx)("h4",{id:"background"},"Background"),Object(r.mdx)("p",null,"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."),Object(r.mdx)("h4",{id:"transformation-framework"},"Transformation Framework"),Object(r.mdx)("p",null,"A transformation framework allows a mechanism to selectively transform an entity or specific attributes of that entity."),Object(r.mdx)("p",null,"To achieve this, the framework provides:"),Object(r.mdx)("ul",null,Object(r.mdx)("li",{parentName:"ul"},"Way to set a condition that needs to be satisfied for a transformation to be applied."),Object(r.mdx)("li",{parentName:"ul"},"Action to be taken on the entity once the condition is met.")),Object(r.mdx)("p",null,"The existing transformation frameworks allowed this to happen."),Object(r.mdx)("h4",{id:"reason-for-new-transformation-framework"},"Reason for New Transformation Framework"),Object(r.mdx)("p",null,"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.\nThe new framework addresses this problem by providing built-in transformations for some commonly used types. It can also be extended to accommodate new types."),Object(r.mdx)("h4",{id:"approach"},"Approach"),Object(r.mdx)("p",null,"The approach used by the new transformation framework creates a transformation by:"),Object(r.mdx)("ul",null,Object(r.mdx)("li",{parentName:"ul"},"Specifying a condition."),Object(r.mdx)("li",{parentName:"ul"},"Specifying action(s) to be taken if the condition is met.")),Object(r.mdx)("h5",{id:"conditions"},"Conditions"),Object(r.mdx)("p",null,"Following are built-in conditions."),Object(r.mdx)("table",null,Object(r.mdx)("thead",{parentName:"table"},Object(r.mdx)("tr",{parentName:"thead"},Object(r.mdx)("th",{parentName:"tr",align:null},Object(r.mdx)("strong",{parentName:"th"},"Condition Types")),Object(r.mdx)("th",{parentName:"tr",align:null},Object(r.mdx)("strong",{parentName:"th"},"Description")))),Object(r.mdx)("tbody",{parentName:"table"},Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"ENTITY_ALL"),Object(r.mdx)("td",{parentName:"tr",align:null},"Any/every entity")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"ENTITY_TOP_LEVEL"),Object(r.mdx)("td",{parentName:"tr",align:null},"Entity that is the top-level entity. This is also the entity present specified in ",Object(r.mdx)("em",{parentName:"td"},"AtlasExportRequest"),".")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"EQUALS"),Object(r.mdx)("td",{parentName:"tr",align:null},"Entity attribute equals to the one specified in the condition.")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"EQUALS_IGNORE_CASE"),Object(r.mdx)("td",{parentName:"tr",align:null},"Entity attribute equals to the one specified in the condition ignoring case.")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"STARTS_WITH"),Object(r.mdx)("td",{parentName:"tr",align:null},"Entity attribute starts with.")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"STARTS_WITH_IGNORE_CASE"),Object(r.mdx)("td",{parentName:"tr",align:null},"Entity attribute starts with ignoring case.")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"HAS_VALUE"),Object(r.mdx)("td",{parentName:"tr",align:null},"Entity attribute has value.")))),Object(r.mdx)("h5",{id:"actions"},"Actions"),Object(r.mdx)("table",null,Object(r.mdx)("thead",{parentName:"table"},Object(r.mdx)("tr",{parentName:"thead"},Object(r.mdx)("th",{parentName:"tr",align:null},Object(r.mdx)("strong",{parentName:"th"},"Action Type")),Object(r.mdx)("th",{parentName:"tr",align:null},"*Description**"))),Object(r.mdx)("tbody",{parentName:"table"},Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"ADD_CLASSIFICATION"),Object(r.mdx)("td",{parentName:"tr",align:null},"Add classification")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"REPLACE_PREFIX"),Object(r.mdx)("td",{parentName:"tr",align:null},"Replace value starting with another value.")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"TO_LOWER"),Object(r.mdx)("td",{parentName:"tr",align:null},"Convert a value of an attribute to lower case.")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"SET"),Object(r.mdx)("td",{parentName:"tr",align:null},"Set the value of an attribute")),Object(r.mdx)("tr",{parentName:"tbody"},Object(r.mdx)("td",{parentName:"tr",align:null},"CLEAR"),Object(r.mdx)("td",{parentName:"tr",align:null},"Clear value of an attribute")))),Object(r.mdx)("h4",{id:"built-in-transforms"},"Built-in Transforms"),Object(r.mdx)("h5",{id:"add-classification"},"Add Classification"),Object(r.mdx)("p",null,"During import, hive",Object(r.mdx)("em",{parentName:"p"},"db entity whose _qualifiedName")," is ",Object(r.mdx)("em",{parentName:"p"},"stocks@cl1")," will get the classification ",Object(r.mdx)("em",{parentName:"p"},"clSrcImported"),"."),Object(r.mdx)(o.a,{wrapLines:!0,language:"json",style:i.a,mdxType:"SyntaxHighlighter"},'{\n "conditions": {\n "hive_db.qualifiedName": "stocks@cl1"\n },\n "action": {\n "__entity": "ADD_CLASSIFICATION: clSrcImported"\n }\n}'),Object(r.mdx)("p",null,"Every imported entity will get the classification by simply changing the condition. The __entity is a special condition which matches entity."),Object(r.mdx)(o.a,{wrapLines:!0,language:"json",style:i.a,mdxType:"SyntaxHighlighter"},'{\n "conditions": {\n "__entity": ""\n },\n "action": {\n "__entity": "ADD_CLASSIFICATION: clSrcImported"\n }\n}'),Object(r.mdx)("p",null,"To add the classification to only the top-level entity (an entity that is used as a starting point for an export), use:"),Object(r.mdx)(o.a,{wrapLines:!0,language:"json",style:i.a,mdxType:"SyntaxHighlighter"},'{\n "conditions": {\n "__entity": "topLevel:"\n },\n "action": {\n "__entity": "ADD_CLASSIFICATION: clSrcImported"\n }\n}'),Object(r.mdx)("h5",{id:"replace-prefix"},"Replace Prefix"),Object(r.mdx)("p",null,"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."),Object(r.mdx)("p",null,"The sample below searches for ",Object(r.mdx)("em",{parentName:"p"},"/aa/bb/"),", once found replaces it with ",Object(r.mdx)("em",{parentName:"p"},"/xx/yy/"),"."),Object(r.mdx)(o.a,{wrapLines:!0,language:"json",style:i.a,mdxType:"SyntaxHighlighter"},'{\n "conditions": {\n "hdfs_path.clusterName": "EQUALS: CL1"\n },\n "action": {\n "hdfs_path.path": "REPLACE_PREFIX: = :/aa/bb/=/xx/yy/"\n }\n}'),Object(r.mdx)("h5",{id:"to-lower"},"To Lower"),Object(r.mdx)("p",null,"Entity whose hdfs_path.clusterName is CL1 will get its path attribute converted to lower case."),Object(r.mdx)(o.a,{wrapLines:!0,language:"json",style:i.a,mdxType:"SyntaxHighlighter"},'{\n "conditions": {\n "hdfs_path.clusterName": "EQUALS: CL1"\n },\n "action": {\n "hdfs_path.path": "TO_LOWER:"\n }\n}'),Object(r.mdx)("h5",{id:"clear"},"Clear"),Object(r.mdx)("p",null,"Entity whose hdfs",Object(r.mdx)("em",{parentName:"p"},"path.clusterName has value set, will get its _replicatedTo")," attribute value cleared."),Object(r.mdx)(o.a,{wrapLines:!0,language:"json",style:i.a,mdxType:"SyntaxHighlighter"},'{\n "conditions": {\n "hdfs_path.clusterName": "HAS_VALUE:"\n },\n "action": {\n "hdfs_path.replicatedTo": "CLEAR:"\n }\n}'),Object(r.mdx)("h4",{id:"additional-examples"},"Additional Examples"),Object(r.mdx)("p",null,"Please look at ",Object(r.mdx)("a",{parentName:"p",href:"https://github.com/apache/atlas/blob/master/intg/src/test/java/org/apache/atlas/entitytransform/TransformationHandlerTest.java"},"these tests")," for examples using Java classes."))}l&&l===Object(l)&&Object.isExtensible(l)&&Object.defineProperty(l,"__filemeta",{enumerable:!0,configurable:!0,value:{name:"MDXContent",filename:"src/documents/Import-Export/ImportEntityTransforms.md"}}),l.isMDXComponent=!0},"./theme/styles/styled-colors.js":function(t,e,a){"use strict";var n=a("../node_modules/react-syntax-highlighter/dist/esm/styles/hljs/dark.js");n.a.hljs.color="#37bb9b",e.a=n.a}}]);
//# sourceMappingURL=documents-import-export-import-entity-transforms.b185f4c5b68d73002af0.js.map