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(mcp): fix mcp key aspect #10503

Merged
Merged
Show file tree
Hide file tree
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
Expand Up @@ -99,14 +99,21 @@ public SystemAspect getSystemAspect(@Nullable Long version) {

@Nonnull
public MetadataChangeProposal getMetadataChangeProposal() {
final MetadataChangeProposal mcp = new MetadataChangeProposal();
mcp.setEntityUrn(getUrn());
mcp.setChangeType(getChangeType());
mcp.setEntityType(getEntitySpec().getName());
mcp.setAspectName(getAspectName());
mcp.setAspect(GenericRecordUtils.serializeAspect(getRecordTemplate()));
mcp.setSystemMetadata(getSystemMetadata());
return mcp;
if (metadataChangeProposal != null) {
return metadataChangeProposal;
} else {
final MetadataChangeProposal mcp = new MetadataChangeProposal();
mcp.setEntityUrn(getUrn());
mcp.setChangeType(getChangeType());
mcp.setEntityType(getEntitySpec().getName());
mcp.setAspectName(getAspectName());
mcp.setAspect(GenericRecordUtils.serializeAspect(getRecordTemplate()));
mcp.setSystemMetadata(getSystemMetadata());
mcp.setEntityKeyAspect(
GenericRecordUtils.serializeAspect(
EntityKeyUtils.convertUrnToEntityKey(getUrn(), entitySpec.getKeyAspectSpec())));
return mcp;
}
}

public static class ChangeItemImplBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import com.linkedin.metadata.service.UpdateIndicesService;
import com.linkedin.metadata.snapshot.CorpUserSnapshot;
import com.linkedin.metadata.snapshot.Snapshot;
import com.linkedin.metadata.utils.EntityKeyUtils;
import com.linkedin.metadata.utils.GenericRecordUtils;
import com.linkedin.mxe.GenericAspect;
import com.linkedin.mxe.MetadataChangeLog;
Expand Down Expand Up @@ -533,6 +534,11 @@ public void testReingestAspectsGetLatestAspects() throws Exception {

initialChangeLog.setAspect(aspect);
initialChangeLog.setSystemMetadata(metadata1);
initialChangeLog.setEntityKeyAspect(
GenericRecordUtils.serializeAspect(
EntityKeyUtils.convertUrnToEntityKey(
entityUrn,
_testEntityRegistry.getEntitySpec(entityUrn.getEntityType()).getKeyAspectSpec())));

final MetadataChangeLog restateChangeLog = new MetadataChangeLog();
restateChangeLog.setEntityType(entityUrn.getEntityType());
Expand Down Expand Up @@ -595,6 +601,11 @@ public void testReingestLineageAspect() throws Exception {

initialChangeLog.setAspect(aspect);
initialChangeLog.setSystemMetadata(metadata1);
initialChangeLog.setEntityKeyAspect(
GenericRecordUtils.serializeAspect(
EntityKeyUtils.convertUrnToEntityKey(
entityUrn,
_testEntityRegistry.getEntitySpec(entityUrn.getEntityType()).getKeyAspectSpec())));

final MetadataChangeLog restateChangeLog = new MetadataChangeLog();
restateChangeLog.setEntityType(entityUrn.getEntityType());
Expand All @@ -606,6 +617,11 @@ public void testReingestLineageAspect() throws Exception {
restateChangeLog.setSystemMetadata(metadata1);
restateChangeLog.setPreviousAspectValue(aspect);
restateChangeLog.setPreviousSystemMetadata(simulatePullFromDB(metadata1, SystemMetadata.class));
restateChangeLog.setEntityKeyAspect(
GenericRecordUtils.serializeAspect(
EntityKeyUtils.convertUrnToEntityKey(
entityUrn,
_testEntityRegistry.getEntitySpec(entityUrn.getEntityType()).getKeyAspectSpec())));

Map<String, RecordTemplate> latestAspects =
_entityServiceImpl.getLatestAspectsForUrn(
Expand Down
Loading