Skip to content

Commit 529836d

Browse files
committed
FIX - OpenMetadata ops bulk deploy via API (#24508)
1 parent 5b1f17c commit 529836d

File tree

5 files changed

+445
-36
lines changed

5 files changed

+445
-36
lines changed

openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityTimeSeriesDAO.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,35 @@ default void deleteBeforeTimestamp(String entityFQNHash, String extension, Long
400400
deleteBeforeTimestamp(getTimeSeriesTableName(), entityFQNHash, extension, timestamp);
401401
}
402402

403+
@ConnectionAwareSqlUpdate(
404+
value =
405+
"DELETE FROM <table> "
406+
+ "WHERE entityFQNHash = :entityFQNHash "
407+
+ "AND extension = :extension "
408+
+ "<mysqlCond>",
409+
connectionType = MYSQL)
410+
@ConnectionAwareSqlUpdate(
411+
value =
412+
"DELETE FROM <table> "
413+
+ "WHERE entityFQNHash = :entityFQNHash "
414+
+ "AND extension = :extension "
415+
+ "<psqlCond>",
416+
connectionType = POSTGRES)
417+
void deleteExtensionByKeyInternal(
418+
@Define("table") String table,
419+
@Bind("value") String value,
420+
@BindFQN("entityFQNHash") String entityFQNHash,
421+
@Bind("extension") String extension,
422+
@Define("mysqlCond") String mysqlCond,
423+
@Define("psqlCond") String psqlCond);
424+
425+
default void deleteExtensionByKey(String key, String value, String entityFQN, String extension) {
426+
String mysqlCond = String.format("AND JSON_UNQUOTE(JSON_EXTRACT(json, '$.%s')) = :value", key);
427+
String psqlCond = String.format("AND json->>'%s' = :value", key);
428+
deleteExtensionByKeyInternal(
429+
getTimeSeriesTableName(), value, entityFQN, extension, mysqlCond, psqlCond);
430+
}
431+
403432
@SqlQuery(
404433
"SELECT json FROM <table> where entityFQNHash = :entityFQNHash and extension = :extension "
405434
+ " AND timestamp >= :startTs and timestamp <= :endTs ORDER BY timestamp DESC")

openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/IngestionPipelineRepository.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,20 @@ public PipelineStatus getPipelineStatus(String ingestionPipelineFQN, UUID pipeli
480480
PipelineStatus.class);
481481
}
482482

483+
@Transaction
484+
public IngestionPipeline deletePipelineStatusByRunId(UUID ingestionPipelineId, UUID runId) {
485+
IngestionPipeline ingestionPipeline = find(ingestionPipelineId, Include.NON_DELETED);
486+
daoCollection
487+
.entityExtensionTimeSeriesDao()
488+
.deleteExtensionByKey(
489+
RUN_ID_EXTENSION_KEY,
490+
runId.toString(),
491+
ingestionPipeline.getFullyQualifiedName(),
492+
PIPELINE_STATUS_EXTENSION);
493+
setFieldsInternal(ingestionPipeline, Fields.EMPTY_FIELDS);
494+
return ingestionPipeline;
495+
}
496+
483497
/**
484498
* Handles entity updated from PUT and POST operation.
485499
*/

openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResource.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,34 @@ public PipelineStatus getPipelineStatus(
12141214
return repository.getPipelineStatus(fqn, runId);
12151215
}
12161216

1217+
@DELETE
1218+
@Path("/{id}/pipelineStatus/{runId}")
1219+
@Operation(
1220+
operationId = "deletePipelineStatusByRunId",
1221+
summary = "Delete pipeline status by run ID",
1222+
description =
1223+
"Delete a specific pipeline status by its run ID for the given ingestion pipeline.",
1224+
responses = {
1225+
@ApiResponse(responseCode = "204", description = "Pipeline status deleted successfully"),
1226+
@ApiResponse(
1227+
responseCode = "404",
1228+
description = "Ingestion Pipeline or Pipeline Status not found")
1229+
})
1230+
public Response deletePipelineStatusByRunId(
1231+
@Context UriInfo uriInfo,
1232+
@Context SecurityContext securityContext,
1233+
@Parameter(description = "Id of the Ingestion Pipeline", schema = @Schema(type = "UUID"))
1234+
@PathParam("id")
1235+
UUID id,
1236+
@Parameter(description = "Run ID of the pipeline status", schema = @Schema(type = "UUID"))
1237+
@PathParam("runId")
1238+
UUID runId) {
1239+
OperationContext operationContext = new OperationContext(entityType, MetadataOperation.DELETE);
1240+
authorizer.authorize(securityContext, operationContext, getResourceContextById(id));
1241+
repository.deletePipelineStatusByRunId(id, runId);
1242+
return Response.noContent().build();
1243+
}
1244+
12171245
@DELETE
12181246
@Path("/{id}/pipelineStatus")
12191247
@Operation(

0 commit comments

Comments
 (0)