In the first MCE in the bootstrap_mce.json ```{ ...
# getting-started
w
In the first MCE in the bootstrap_mce.json
Copy code
{
    "auditHeader": null,
    "proposedSnapshot": {
      "com.linkedin.pegasus2avro.metadata.snapshot.CorpUserSnapshot": {
        "urn": "urn:li:corpuser:datahub",
        "aspects": [
          {
            "com.linkedin.pegasus2avro.identity.CorpUserInfo": {
              "active": true,
              "displayName": {
                "string": "Data Hub"
              },
              "email": "<mailto:datahub@linkedin.com|datahub@linkedin.com>",
              "title": {
                "string": "CEO"
              },
              "fullName": {
                "string": "Data Hub"
              },
            }
          }
        ]
      }
    },
    "proposedDelta": null
  },
CorpUserKey
(with a field
username
) is the Key Aspect for the entity
CorpUserSnapshot
(as in the definition of CorpUserSnapshot.pdl). But I don't see any
username
field and value in this JSON element. Could anyone help me understand this anomaly? @mammoth-bear-12532 @big-carpet-38439
I found out with my colleague's help this:
Copy code
metadata-utils/src/main/java/com/linkedin/metadata/utils/EntityKeyUtils.java

@Nonnull
  public static Urn getUrnFromLog(MetadataChangeLog metadataChangeLog) {
    if (metadataChangeLog.hasEntityUrn() && metadataChangeLog.hasEntityKeyAspect()) {
      throw new IllegalArgumentException("Urn and keyAspect cannot both be set");
    }
    ...
}
Is this the reason key aspect (CorpUserKey) is not present as urn
"urn:li:corpuser:datahub"
is already set?
Then I also see this:
Copy code
if (metadataChangeLog.hasEntityKeyAspect()) {
      throw new UnsupportedOperationException("Identifying entity with key aspect is not yet supported");
    }
Is Entity instance ID based on key aspect not supported yet? I checked the call hierarchy for getUrnFromLog() method, and found it's called only from:
com.linkedin.metadata.kafka.MetadataChangeLogProcessor#consume
..which is not called from anywhere! I think I'm missing something basic here. Could anyone please help here to clear my doubt?
b
Yes this is described in the docs. URNs are a stringified representation of the key aspect that serves as a primary key
Copy code
com.linkedin.metadata.kafka.MetadataChangeLogProcessor#consume
is invoked when a Kafka event on the MetadataChangeLog topic is handled by the service. But thanks for catching this, we actually should be supporting identifying the entity with the key aspect alone. The idea is that someone producing metadata can either provide the key aspect object or the urn
w
@big-carpet-38439 You mentioned "URNs are a stringified representation of the key aspect that serves as a primary key". I also read it in the docs. The @Entity annotation says that
name
and
corpUserKey
aspect are both required.
Copy code
@Entity = {
  "name": "corpuser",
  "keyAspect": "corpUserKey"
}
record CorpUserSnapshot {
  urn: CorpuserUrn
  aspects: array[CorpUserAspect]
}
Now, within the CorpUserSnapshot JSON instance, it doesn't seem correct to say that mention of only a URN
"urn": "urn:li:corpuser:datahub"
covers for both the
CorpUserSnapshot --> urn
field and
corpUserKey
aspect. OR, is that correct actually? I'm confused how to utilize the metadata model with proper understanding and precision. If I declare a new entity along with its key aspect, would the fields of key aspect be optional to mention in the instance of the entity?