Skip to content

Commit 7ef81e8

Browse files
authored
HCK-16067: Add support for FE of tags to DataHub (#260)
* HCK-16067: implement FE of tags to DataHub * Fix DataHub tag detection if a tag with the same name exists in different schemas
1 parent e5541cc commit 7ef81e8

2 files changed

Lines changed: 69 additions & 3 deletions

File tree

forward_engineering/config.json

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,27 @@
455455
"name": "database"
456456
}
457457
},
458-
"Schema"
458+
{
459+
"type": "Schema",
460+
"source": "container",
461+
"properties": {
462+
"tags": "schemaTags"
463+
}
464+
}
465+
],
466+
"datasets": [
467+
{
468+
"type": "Table",
469+
"source": "collection",
470+
"properties": { "tags": "tableTags" }
471+
},
472+
{
473+
"type": "View",
474+
"source": "view",
475+
"properties": { "tags": "viewTags" }
476+
}
459477
],
460-
"datasets": ["Table", "View"],
478+
"fieldProperties": { "tags": "columnTags" },
461479
"typeMapping": {
462480
"DATE": "DateType",
463481
"BIGINT": "NumberType",
@@ -501,6 +519,13 @@
501519
"convertUrnsToLowerCase": {
502520
"use": true,
503521
"default": true
522+
},
523+
"exportTags": {
524+
"use": true,
525+
"type": "select",
526+
"options": ["skip", "with_lineage", "without_lineage"],
527+
"default": "skip",
528+
"propagateTags": "with_lineage"
504529
}
505530
},
506531
"viewLanguage": "SQL"

forward_engineering/dataHubProvider.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const { toLower } = require('lodash');
88

99
const types = require('./configs/types');
1010
const defaultTypes = require('./configs/defaultTypes');
11-
const getKeyHelper = require('./helpers/keyHelper');
1211
const getColumnDefinitionHelper = require('./helpers/columnDefinitionHelper');
1312
const { createView, hydrateView, hydrateViewColumn } = require('./helpers/viewHelper');
1413
const { FORMATS } = require('./helpers/constants');
@@ -106,6 +105,48 @@ class DataHubProvider {
106105
},
107106
};
108107
}
108+
109+
getTags({ data, containerAssets, options }) {
110+
if (options.exportTags === 'skip') {
111+
return [];
112+
}
113+
114+
return data.containers
115+
.flatMap(container => {
116+
const containerObject = this.#mergeTabs(container.containerData);
117+
const containerAsset = containerAssets.find(asset => asset.hackoladeMeta?.bucketId === container.id);
118+
119+
if (!containerAsset) {
120+
throw new Error(
121+
`The the container asset for the "${containerObject.code ?? containerObject.name}" is not found!`,
122+
);
123+
}
124+
125+
if (!containerAsset.hackoladeMeta) {
126+
throw new Error(
127+
`The "database" and "schema" of the container asset "${containerAsset.containerProperties.value.name}" are not found!`,
128+
);
129+
}
130+
131+
return (containerObject.tags ?? [])?.flatMap(tag => {
132+
return (tag.allowedValues ?? []).map(tagValue => {
133+
return {
134+
displayName: `${tag.name}: ${tagValue.value}`,
135+
name: `${containerAsset.hackoladeMeta?.database}.${containerAsset.hackoladeMeta?.schema}.${tag.name}:${tagValue.value}`,
136+
resolutionData: {
137+
tagName: tag.id,
138+
tagValue: tagValue.id,
139+
},
140+
};
141+
});
142+
});
143+
})
144+
.filter(Boolean);
145+
}
146+
147+
#mergeTabs(tabsData) {
148+
return tabsData.reduce((acc, current) => Object.assign(acc, current), {});
149+
}
109150
}
110151

111152
module.exports = DataHubProvider;

0 commit comments

Comments
 (0)