fix: DELETE endpoint for profiler data (#12912)

This commit is contained in:
Teddy 2023-08-18 20:48:04 +02:00 committed by GitHub
parent a45c644bc4
commit edea862082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -402,16 +402,21 @@ public class TableRepository extends EntityRepository<Table> {
public void deleteTableProfile(String fqn, String entityType, Long timestamp) { public void deleteTableProfile(String fqn, String entityType, Long timestamp) {
// Validate the request content // Validate the request content
String extension; String extension;
Class classMapper;
if (entityType.equalsIgnoreCase(Entity.TABLE)) { if (entityType.equalsIgnoreCase(Entity.TABLE)) {
extension = TABLE_PROFILE_EXTENSION; extension = TABLE_PROFILE_EXTENSION;
classMapper = TableProfile.class;
} else if (entityType.equalsIgnoreCase("column")) { } else if (entityType.equalsIgnoreCase("column")) {
extension = TABLE_COLUMN_PROFILE_EXTENSION; extension = TABLE_COLUMN_PROFILE_EXTENSION;
classMapper = ColumnProfile.class;
} else if (entityType.equalsIgnoreCase("system")) {
extension = SYSTEM_PROFILE_EXTENSION;
classMapper = SystemProfile.class;
} else { } else {
throw new IllegalArgumentException("entityType must be table or column"); throw new IllegalArgumentException("entityType must be table, column or system");
} }
TableProfile storedTableProfile = Object storedTableProfile = JsonUtils.readValue(getExtensionAtTimestamp(fqn, extension, timestamp), classMapper);
JsonUtils.readValue(getExtensionAtTimestamp(fqn, extension, timestamp), TableProfile.class);
if (storedTableProfile == null) { if (storedTableProfile == null) {
throw new EntityNotFoundException(String.format("Failed to find table profile for %s at %s", fqn, timestamp)); throw new EntityNotFoundException(String.format("Failed to find table profile for %s at %s", fqn, timestamp));
} }