Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bootstrap): skip ingesting data platforms that already exist #5382

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.linkedin.metadata.boot.steps;

import com.datahub.util.RecordUtils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.linkedin.common.AuditStamp;
import com.linkedin.common.urn.Urn;
import com.linkedin.dataplatform.DataPlatformInfo;
import com.linkedin.metadata.Constants;
import com.linkedin.metadata.boot.BootstrapStep;
import com.datahub.util.RecordUtils;
import com.linkedin.metadata.entity.EntityService;

import java.io.IOException;
import java.net.URISyntaxException;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
Expand Down Expand Up @@ -46,13 +44,24 @@ public void execute() throws IOException, URISyntaxException {

// 2. For each JSON object, cast into a DataPlatformSnapshot object.
for (final JsonNode dataPlatform : dataPlatforms) {
final String urnString;
final Urn urn;
try {
urn = Urn.createFromString(dataPlatform.get("urn").asText());
urnString = dataPlatform.get("urn").asText();
urn = Urn.createFromString(urnString);
} catch (URISyntaxException e) {
log.error("Malformed urn: {}", dataPlatform.get("urn").asText());
throw new RuntimeException("Malformed urn", e);
}

final DataPlatformInfo existingInfo =
(DataPlatformInfo) _entityService.getLatestAspect(urn, PLATFORM_ASPECT_NAME);
// Skip ingesting for this JSON object if info already exists.
if (existingInfo != null) {
log.debug(String.format("%s already exists for %s. Skipping...", PLATFORM_ASPECT_NAME, urnString));
continue;
}

final DataPlatformInfo info =
RecordUtils.toRecordTemplate(DataPlatformInfo.class, dataPlatform.get("aspect").toString());

Expand Down