Skip to content

Commit

Permalink
HCK-8808: removed memory-optimized tables data retrievment (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilhelmWesser authored Nov 21, 2024
1 parent 6eaf517 commit 0bfd723
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 46 deletions.
25 changes: 0 additions & 25 deletions reverse_engineering/databaseService/databaseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,30 +300,6 @@ const getTableColumnsDescription = async (connectionClient, dbName, tableName, s
`);
};

const getDatabaseMemoryOptimizedTables = async (connectionClient, dbName, logger) => {
try {
const currentDbConnectionClient = await getNewConnectionClientByDb(connectionClient, dbName);

logger.log('info', { message: `Get '${dbName}' database memory optimized indexes.` }, 'Reverse Engineering');

return mapResponse(currentDbConnectionClient.query`
SELECT
T.name,
T.durability,
T.durability_desc,
OBJECT_NAME(T.history_table_id) AS history_table,
SCHEMA_NAME(O.schema_id) AS history_schema,
T.temporal_type_desc
FROM sys.tables T LEFT JOIN sys.objects O ON T.history_table_id = O.object_id
WHERE T.is_memory_optimized=1
`);
} catch (error) {
logger.log('error', { message: error.message, stack: error.stack, error }, 'Retrieve memory optimized tables');

return [];
}
};

const getViewColumns = async (connectionClient, dbName, viewName, schemaName) => {
const currentDbConnectionClient = await getNewConnectionClientByDb(connectionClient, dbName);
const objectId = `${schemaName}.${viewName}`;
Expand Down Expand Up @@ -480,7 +456,6 @@ module.exports = {
getTableForeignKeys,
getDatabaseIndexes,
getTableColumnsDescription,
getDatabaseMemoryOptimizedTables,
getViewTableInfo,
getTableKeyConstraints,
getTableMaskedColumns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const {
getTableForeignKeys,
getDatabaseIndexes,
getTableColumnsDescription,
getDatabaseMemoryOptimizedTables,
getViewTableInfo,
getViewColumns,
getTableKeyConstraints,
Expand Down Expand Up @@ -312,21 +311,6 @@ const cleanDocuments = documents => {
return documents.map(cleanNull);
};

const getMemoryOptimizedOptions = options => {
if (!options) {
return {};
}

return {
memory_optimized: true,
durability: ['SCHEMA_ONLY', 'SCHEMA_AND_DATA'].includes(String(options.durability_desc).toUpperCase())
? String(options.durability_desc).toUpperCase()
: '',
systemVersioning: options.temporal_type_desc === 'SYSTEM_VERSIONED_TEMPORAL_TABLE',
historyTable: options.history_table ? `${options.history_schema}.${options.history_table}` : '',
};
};

const getDistribution = distributionData => {
if (!Array.isArray(distributionData) || !distributionData.length) {
return '';
Expand Down Expand Up @@ -386,11 +370,8 @@ const getPersistence = tableName => {
const reverseCollectionsToJSON = logger => async (dbConnectionClient, tablesInfo, reverseEngineeringOptions) => {
const dbName = dbConnectionClient.config.database;
progress(logger, `RE data from database "${dbName}"`, dbName);
const [databaseIndexes, databaseMemoryOptimizedTables, databaseUDT, dataBasePartitions] = await Promise.all([
const [databaseIndexes, databaseUDT, dataBasePartitions] = await Promise.all([
getDatabaseIndexes(dbConnectionClient, dbName, logger).catch(logError(logger, 'Getting indexes')),
getDatabaseMemoryOptimizedTables(dbConnectionClient, dbName, logger).catch(
logError(logger, 'Getting memory optimized tables'),
),
getDatabaseUserDefinedTypes(dbConnectionClient, dbName, logger).catch(
logError(logger, 'Getting user defined types'),
),
Expand Down Expand Up @@ -498,7 +479,6 @@ const reverseCollectionsToJSON = logger => async (dbConnectionClient, tablesInfo
dbName: schemaName,
entityLevel: {
Indxs: reverseTableIndexes(tableIndexes),
...getMemoryOptimizedOptions(databaseMemoryOptimizedTables.find(item => item.name === tableName)),
...defineFieldsCompositeKeyConstraints(fieldsKeyConstraints),
indexingOrderColumn: order.map(column => ({ name: column })),
tableRole: getTableRole(distribution, indexing),
Expand Down

0 comments on commit 0bfd723

Please sign in to comment.