Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions forward_engineering/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,27 @@
"name": "database"
}
},
"Schema"
{
"type": "Schema",
"source": "container",
"properties": {
"tags": "schemaTags"
}
}
],
"datasets": [
{
"type": "Table",
"source": "collection",
"properties": { "tags": "tableTags" }
},
{
"type": "View",
"source": "view",
"properties": { "tags": "viewTags" }
}
],
"datasets": ["Table", "View"],
"fieldProperties": { "tags": "columnTags" },
"typeMapping": {
"DATE": "DateType",
"BIGINT": "NumberType",
Expand Down Expand Up @@ -501,6 +519,13 @@
"convertUrnsToLowerCase": {
"use": true,
"default": true
},
"exportTags": {
"use": true,
"type": "select",
"options": ["skip", "with_lineage", "without_lineage"],
"default": "skip",
"propagateTags": "with_lineage"
}
},
"viewLanguage": "SQL"
Expand Down
43 changes: 42 additions & 1 deletion forward_engineering/dataHubProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { toLower } = require('lodash');

const types = require('./configs/types');
const defaultTypes = require('./configs/defaultTypes');
const getKeyHelper = require('./helpers/keyHelper');
const getColumnDefinitionHelper = require('./helpers/columnDefinitionHelper');
const { createView, hydrateView, hydrateViewColumn } = require('./helpers/viewHelper');
const { FORMATS } = require('./helpers/constants');
Expand Down Expand Up @@ -106,6 +105,48 @@ class DataHubProvider {
},
};
}

getTags({ data, containerAssets, options }) {
if (options.exportTags === 'skip') {
return [];
}

return data.containers
.flatMap(container => {
const containerObject = this.#mergeTabs(container.containerData);
const containerAsset = containerAssets.find(asset => asset.hackoladeMeta?.bucketId === container.id);

if (!containerAsset) {
throw new Error(
`The the container asset for the "${containerObject.code ?? containerObject.name}" is not found!`,
);
}

if (!containerAsset.hackoladeMeta) {
throw new Error(
`The "database" and "schema" of the container asset "${containerAsset.containerProperties.value.name}" are not found!`,
);
}

return (containerObject.tags ?? [])?.flatMap(tag => {
return (tag.allowedValues ?? []).map(tagValue => {
return {
displayName: `${tag.name}: ${tagValue.value}`,
name: `${containerAsset.hackoladeMeta?.database}.${containerAsset.hackoladeMeta?.schema}.${tag.name}:${tagValue.value}`,
resolutionData: {
tagName: tag.id,
tagValue: tagValue.id,
},
};
});
});
})
.filter(Boolean);
}

#mergeTabs(tabsData) {
return tabsData.reduce((acc, current) => Object.assign(acc, current), {});
}
}

module.exports = DataHubProvider;
Loading