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 (#121)

* HCK-8696: add filtering of duplicated indexes columns for case with indexes on partitioned tables

* HCK-8696: removed redundant Boolean call
  • Loading branch information
WilhelmWesser authored Nov 25, 2024
1 parent c05efdf commit 225bfdb
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 = !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 @@ -42,6 +42,7 @@ const {
getPeriodForSystemTime,
} = require('./helpers');
const pipe = require('../helpers/pipe');
const { getUniqueIndexesColumns } = require('./helpers/getUniqueIndexesColumns');

const mergeCollectionsWithViews = ({ jsonSchemas }) => {
const [viewSchemas, collectionSchemas] = partition(jsonSchemas, jsonSchema => jsonSchema.relatedTables);
Expand Down Expand Up @@ -309,7 +310,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 225bfdb

Please sign in to comment.