Skip to content

Commit

Permalink
HCK-8696: add filtering of duplicated indexes columns for case with i…
Browse files Browse the repository at this point in the history
…ndexes on partitioned tables
  • Loading branch information
WilhelmWesser committed Nov 14, 2024
1 parent 874ff0f commit f734f56
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const getColumnUniqueKey = ({ IndexName, TableName, schemaName, columnName }) =>
`${schemaName}${IndexName}${TableName}${columnName}`;

const getUniqueIndexesColumns = ({ indexesColumns }) => {
const uniqueKeysToColumns = {};

for (const indexesColumn of indexesColumns) {
const columnKey = getColumnUniqueKey(indexesColumn);
const isColumnUnique = !Boolean(uniqueKeysToColumns[columnKey]);

if (!isColumnUnique) {
continue;
}

uniqueKeysToColumns[columnKey] = indexesColumn;
}

return Object.values(uniqueKeysToColumns);
};

module.exports = {
getUniqueIndexesColumns,
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const {
getPeriodForSystemTime,
} = require('./helpers');
const pipe = require('../helpers/pipe');
const { getUniqueIndexesColumns } = require('./helpers/getUniqueIndexesColumns');

const mergeCollectionsWithViews = jsonSchemas =>
jsonSchemas.reduce((structuredJSONSchemas, jsonSchema) => {
Expand Down Expand Up @@ -315,7 +316,8 @@ const reverseCollectionsToJSON = logger => async (dbConnectionClient, tablesInfo
rawDatabaseIndexes.map(i => i.index_id),
logger,
);
const databaseIndexes = addTotalBucketCountToDatabaseIndexes(rawDatabaseIndexes, indexesBucketCount);
const uniqueDatabaseIndexesColumns = getUniqueIndexesColumns({ indexesColumns: rawDatabaseIndexes });
const databaseIndexes = addTotalBucketCountToDatabaseIndexes(uniqueDatabaseIndexesColumns, indexesBucketCount);

return await Object.entries(tablesInfo).reduce(async (jsonSchemas, [schemaName, tableNames]) => {
logger.log('info', { message: `Fetching '${dbName}' database information` }, 'Reverse Engineering');
Expand Down

0 comments on commit f734f56

Please sign in to comment.