Skip to content

Commit

Permalink
fix(ingestProposal): fix/handle no-op ingestion (datahub-project#10126)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker authored Mar 25, 2024
1 parent fc03a1c commit 45f6c2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -747,10 +747,12 @@ public String ingestProposal(
.mcps(List.of(metadataChangeProposal), auditStamp, entityService)
.build();

IngestResult one = entityService.ingestProposal(batch, async).stream().findFirst().get();
Optional<IngestResult> one = entityService.ingestProposal(batch, async).stream().findFirst();

Urn urn = one.getUrn();
tryIndexRunId(urn, metadataChangeProposal.getSystemMetadata());
Urn urn = one.map(IngestResult::getUrn).orElse(metadataChangeProposal.getEntityUrn());
if (one.isPresent()) {
tryIndexRunId(urn, metadataChangeProposal.getSystemMetadata());
}
return urn.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ public Task<String> ingestProposal(
Set<IngestResult> results =
_entityService.ingestProposal(batch, asyncBool);

IngestResult one = results.stream().findFirst().get();
java.util.Optional<IngestResult> one = results.stream().findFirst();

// Update runIds, only works for existing documents, so ES document must exist
Urn resultUrn = one.getUrn();
if (one.isProcessedMCL() || one.isUpdate()) {
Urn resultUrn = one.map(IngestResult::getUrn).orElse(metadataChangeProposal.getEntityUrn());
if (one.map(result -> result.isProcessedMCL() || result.isUpdate()).orElse(false)) {
tryIndexRunId(
resultUrn, metadataChangeProposal.getSystemMetadata(), entitySearchService);
}
Expand Down

0 comments on commit 45f6c2a

Please sign in to comment.