Skip to content

Commit c4804bd

Browse files
fix(metric): use lighter import lookup and correct async response schema
- MetricCsv.createEntity now uses findByNameOrNull instead of Entity.getEntityByName with all fields, avoiding a per-row fetch of every related field. The CSV row is the source of truth for all writable fields anyway. - importMetricsAsync OpenAPI annotation now declares CSVImportResponse (jobId/message) instead of CsvImportResult, matching what importCsvInternalAsync actually returns.
1 parent e184d66 commit c4804bd

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,10 @@ protected void createEntity(CSVPrinter printer, List<CSVRecord> csvRecords) thro
516516
}
517517

518518
String metricName = csvRecord.get(0);
519-
// Metric FQN is just the name (no parent in current schema)
520-
Metric metric;
521-
try {
522-
metric = Entity.getEntityByName(METRIC, metricName, "*", Include.NON_DELETED);
523-
} catch (EntityNotFoundException ex) {
524-
LOG.debug("Metric not found: {}, it will be created during import.", metricName);
519+
// Metric FQN is just the name (no parent in current schema). Use a lightweight
520+
// existence-check lookup; fields populated below from the CSV row are the source of truth.
521+
Metric metric = findByNameOrNull(metricName, Include.NON_DELETED);
522+
if (metric == null) {
525523
metric = new Metric().withName(metricName).withFullyQualifiedName(metricName);
526524
}
527525

openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.openmetadata.service.resources.EntityResource;
6666
import org.openmetadata.service.security.Authorizer;
6767
import org.openmetadata.service.util.CSVExportResponse;
68+
import org.openmetadata.service.util.CSVImportResponse;
6869

6970
@Path("/v1/metrics")
7071
@Tag(
@@ -727,7 +728,7 @@ public CsvImportResult importCsv(
727728
content =
728729
@Content(
729730
mediaType = "application/json",
730-
schema = @Schema(implementation = CsvImportResult.class)))
731+
schema = @Schema(implementation = CSVImportResponse.class)))
731732
})
732733
public Response importCsvAsync(
733734
@Context UriInfo uriInfo,

0 commit comments

Comments
 (0)