mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-12 00:39:08 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
051fb6e4dd | ||
|
|
e3099aa2b2 | ||
|
|
12c61d9b5d |
@@ -1066,8 +1066,8 @@ export class PlatformApiController {
|
|||||||
const rollbackSteps: Array<() => Promise<void>> = [];
|
const rollbackSteps: Array<() => Promise<void>> = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dataAsset = await this.elasticsearchService.findDataAssetByPipelineAndTable(
|
const dataAsset = await this.elasticsearchService.findDataAssetByTable(
|
||||||
user.customer_name, pipelineId, oldTableName, oldTableSchema,
|
user.customer_name, oldTableName, oldTableSchema,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!dataAsset) {
|
if (!dataAsset) {
|
||||||
@@ -1086,26 +1086,31 @@ export class PlatformApiController {
|
|||||||
{ name: oldTableName, table_name: oldTableName, table_schema: oldTableSchema, display_name: oldTableName },
|
{ name: oldTableName, table_name: oldTableName, table_schema: oldTableSchema, display_name: oldTableName },
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const newTableNameUpper = newValues.table_name.toUpperCase();
|
||||||
|
const newTableSchemaUpper = newValues.table_schema.toUpperCase();
|
||||||
|
const oldTableNameUpper = oldTableName.toUpperCase();
|
||||||
|
const oldTableSchemaUpper = oldTableSchema.toUpperCase();
|
||||||
|
|
||||||
// Nimbus table-metadata
|
// Nimbus table-metadata
|
||||||
if (nimbusId) {
|
if (nimbusId) {
|
||||||
await this.catalogService.renameTableOnNimbus(nimbusUrl, nimbusId, newValues);
|
await this.catalogService.renameTableOnNimbus(nimbusUrl, nimbusId, { table_name: newTableNameUpper, table_schema: newTableSchemaUpper });
|
||||||
rollbackSteps.push(() => this.catalogService.renameTableOnNimbus(nimbusUrl, nimbusId, oldValues));
|
rollbackSteps.push(() => this.catalogService.renameTableOnNimbus(nimbusUrl, nimbusId, { table_name: oldTableNameUpper, table_schema: oldTableSchemaUpper }));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nimbus column-metadata
|
// Nimbus column-metadata
|
||||||
await this.catalogService.renameColumnMetadataOnNimbus(
|
await this.catalogService.renameColumnMetadataOnNimbus(
|
||||||
nimbusUrl, databaseName, oldTableName, oldTableSchema, newValues.table_name, newValues.table_schema,
|
nimbusUrl, databaseName, oldTableNameUpper, oldTableSchemaUpper, newTableNameUpper, newTableSchemaUpper,
|
||||||
);
|
);
|
||||||
rollbackSteps.push(() => this.catalogService.renameColumnMetadataOnNimbus(
|
rollbackSteps.push(() => this.catalogService.renameColumnMetadataOnNimbus(
|
||||||
nimbusUrl, databaseName, newValues.table_name, newValues.table_schema, oldTableName, oldTableSchema,
|
nimbusUrl, databaseName, newTableNameUpper, newTableSchemaUpper, oldTableNameUpper, oldTableSchemaUpper,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Nimbus data-preview
|
// Nimbus data-preview
|
||||||
await this.catalogService.renameDataPreviewOnNimbus(
|
await this.catalogService.renameDataPreviewOnNimbus(
|
||||||
nimbusUrl, databaseName, oldTableName, oldTableSchema, newValues.table_name, newValues.table_schema,
|
nimbusUrl, databaseName, oldTableNameUpper, oldTableSchemaUpper, newTableNameUpper, newTableSchemaUpper,
|
||||||
);
|
);
|
||||||
rollbackSteps.push(() => this.catalogService.renameDataPreviewOnNimbus(
|
rollbackSteps.push(() => this.catalogService.renameDataPreviewOnNimbus(
|
||||||
nimbusUrl, databaseName, newValues.table_name, newValues.table_schema, oldTableName, oldTableSchema,
|
nimbusUrl, databaseName, newTableNameUpper, newTableSchemaUpper, oldTableNameUpper, oldTableSchemaUpper,
|
||||||
));
|
));
|
||||||
|
|
||||||
this.logger.info(`Synced catalog rename for ${key}`, { jobId, oldTableName, newTableName: newValues.table_name });
|
this.logger.info(`Synced catalog rename for ${key}`, { jobId, oldTableName, newTableName: newValues.table_name });
|
||||||
|
|||||||
@@ -362,9 +362,8 @@ export class ElasticsearchService {
|
|||||||
return `${customerName}_data_assets_catalog`;
|
return `${customerName}_data_assets_catalog`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findDataAssetByPipelineAndTable(
|
async findDataAssetByTable(
|
||||||
customerName: string,
|
customerName: string,
|
||||||
pipelineId: string,
|
|
||||||
tableName: string,
|
tableName: string,
|
||||||
tableSchema: string,
|
tableSchema: string,
|
||||||
): Promise<{ id: string; nimbus_id: number | null; [key: string]: any } | null> {
|
): Promise<{ id: string; nimbus_id: number | null; [key: string]: any } | null> {
|
||||||
@@ -372,7 +371,6 @@ export class ElasticsearchService {
|
|||||||
|
|
||||||
this.logger.info('Elasticsearch: Searching data asset', {
|
this.logger.info('Elasticsearch: Searching data asset', {
|
||||||
index,
|
index,
|
||||||
pipelineId,
|
|
||||||
tableName,
|
tableName,
|
||||||
tableSchema,
|
tableSchema,
|
||||||
});
|
});
|
||||||
@@ -382,9 +380,8 @@ export class ElasticsearchService {
|
|||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
must: [
|
must: [
|
||||||
{ term: { 'pipeline_id.keyword': pipelineId } },
|
{ term: { 'table_name.keyword': tableName.toUpperCase() } },
|
||||||
{ term: { 'table_name.keyword': tableName } },
|
{ term: { 'table_schema.keyword': tableSchema.toUpperCase() } },
|
||||||
{ term: { 'table_schema.keyword': tableSchema } },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -393,13 +390,13 @@ export class ElasticsearchService {
|
|||||||
|
|
||||||
const hits = response.data.hits?.hits || [];
|
const hits = response.data.hits?.hits || [];
|
||||||
if (hits.length === 0) {
|
if (hits.length === 0) {
|
||||||
this.logger.warn('Elasticsearch: Data asset not found', { pipelineId, tableName, tableSchema, index });
|
this.logger.warn('Elasticsearch: Data asset not found', { tableName, tableSchema, index });
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { ...hits[0]._source, _es_id: hits[0]._id };
|
return { ...hits[0]._source, _es_id: hits[0]._id };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.handleError('findDataAssetByPipelineAndTable', error, { pipelineId, tableName, tableSchema, index });
|
this.handleError('findDataAssetByTable', error, { tableName, tableSchema, index });
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user