fix(entity registry): Fix patching aspects onto existing Config based entity (#7624)

This commit is contained in:
John Joyce 2023-03-20 21:14:09 -07:00 committed by GitHub
parent 482431bcf4
commit 2978cdb409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import com.linkedin.data.schema.compatibility.CompatibilityChecker;
import com.linkedin.data.schema.compatibility.CompatibilityOptions;
import com.linkedin.data.schema.compatibility.CompatibilityResult;
import com.linkedin.metadata.models.AspectSpec;
import com.linkedin.metadata.models.ConfigEntitySpec;
import com.linkedin.metadata.models.DefaultEntitySpec;
import com.linkedin.metadata.models.EntitySpec;
import com.linkedin.metadata.models.EventSpec;
@ -108,6 +109,13 @@ public class MergedEntityRegistry implements EntityRegistry {
private EntitySpec mergeEntitySpecs(EntitySpec existingEntitySpec, EntitySpec newEntitySpec) {
Map<String, AspectSpec> aspectSpecMap = new HashMap<>(existingEntitySpec.getAspectSpecMap());
aspectSpecMap.putAll(newEntitySpec.getAspectSpecMap());
// If the base is a config spec, always create another config spec.
if (existingEntitySpec instanceof ConfigEntitySpec) {
return new ConfigEntitySpec(
existingEntitySpec.getEntityAnnotation().getName(),
existingEntitySpec.getEntityAnnotation().getKeyAspect(),
aspectSpecMap.values());
}
return new DefaultEntitySpec(aspectSpecMap.values(), existingEntitySpec.getEntityAnnotation(),
existingEntitySpec.getSnapshotSchema(), existingEntitySpec.getAspectTyperefSchema());
}

View File

@ -3,3 +3,6 @@ entities:
- name: dataset
aspects:
- customDataQualityRules
- name: container
aspects:
- customDataQualityRules