rhombic
Version:
SQL parsing, lineage extraction and manipulation
63 lines • 1.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLineageTests = exports.getTable = exports.TESTS_PATH = void 0;
const fs_1 = require("fs");
exports.TESTS_PATH = `${__dirname}/`;
const columnsMapping = {
account: ["account_type", "account_id", "account_description", "account_parent", "account_rollup"],
employee: [
"birth_date",
"department_id",
"education_level",
"employee_id",
"end_date",
"first_name",
"full_name",
"gender",
"hire_date",
"last_name",
"management_role",
"marital_status",
"position_id",
"position_title",
"salary",
"store_id",
"supervisor_id"
],
salary: [
"currency_id",
"department_id",
"employee_id",
"overtime_paid",
"pay_date",
"salary_paid",
"vacation_accrued",
"vacation_used"
]
};
const getTable = (table) => {
if (!(table.tableName in columnsMapping)) {
return undefined;
}
const columnNames = columnsMapping[table.tableName];
const columns = columnNames.map(columnId => ({
id: columnId,
data: { id: columnId, tableId: table.tableName }
}));
return {
table: { id: table.tableName, data: { id: table.tableName } },
columns
};
};
exports.getTable = getTable;
const getLineageTests = () => fs_1.readdirSync(exports.TESTS_PATH)
.filter(s => s.endsWith(".json"))
.map(file => {
const raw = fs_1.readFileSync(`${exports.TESTS_PATH}/${file}`);
const name = file.slice(0, -".json".length);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const testCase = JSON.parse(raw.toString());
return { file, name, testCase };
});
exports.getLineageTests = getLineageTests;
//# sourceMappingURL=getLineageTests.js.map