Error Encountered when Emitting List of Aspects in MetadataChangeProposal

Original Slack Thread

<@U06TM7M40RK> getting error when i use list of aspects while emmiting mcp. AttributeError: ‘list’ object has no attribute ‘get_aspect_name’

It seems like you are encountering an error when trying to emit multiple aspects in a MetadataChangeProposal (MCP). The error message AttributeError: 'list' object has no attribute 'get_aspect_name' suggests that the code is attempting to call a method on a list object that does not exist.

According to the <Slack Slack conversation>, it is not possible to emit multiple aspects in a single MCP. Each MCP provides a new value for a given aspect. However, you can emit multiple MCPs together by using an ArrayList to group them and then emit them at once.

Here is an example in Java on how to achieve this:

import com.linkedin.metadata.models.registry.ConfigEntityRegistry;
import com.linkedin.metadata.models.registry.MetadataChangeProposalWrapper;
import java.util.ArrayList;

public class EmitMultipleAspects {
    public static void main(String[] args) {
        ArrayList<MetadataChangeProposalWrapper> mcps = new ArrayList<>();

        // Add MCP for dataset
        mcps.add(MetadataChangeProposalWrapper.create(
            b -> b.entityType("dataset")
                  .entityUrn("urn:li:dataset:(urn:li:dataPlatform:my_platform,foo,TEST)")
                  .upsert()
                  .aspect(new DatasetAspect())
                  .aspectName("datasetAspectName")
        ));

        // Add MCP for schema fields
        mcps.add(MetadataChangeProposalWrapper.create(
            b -> b.entityType("schema")
                  .entityUrn("urn:li:schema:(urn:li:dataPlatform:my_platform,foo,TEST)")
                  .upsert()
                  .aspect(new SchemaAspect())
                  .aspectName("schemaAspectName")
        ));

        // Emit all MCPs
        emitter.emit(mcps);
    }
}

In this example, DatasetAspect and SchemaAspect are placeholders for the actual aspect classes you are using. You need to replace them with the appropriate aspect classes.

Would you like more detailed guidance on this process or any specific part of it?

Sources:

  • <Slack Slack conversation> :+1: 0 button :-1: 0 button :bulb: Hint: Mention @runllm in the thread for followups.

Hey there! :wave: Make sure your message includes the following information if relevant, so we can help more effectively!

  1. Are you using UI or CLI for ingestion?
  2. Which DataHub version are you using? (e.g. 0.12.0)
  3. What data source(s) are you integrating with DataHub? (e.g. BigQuery)

<@U06TM7M40RK> Can you help with the questions in this thread?


:information_source: We’re experimenting with a new AI assistant for questions in the <#CUMUWQU66> channel to help you track down helpful resources more quickly. Keep in mind that responses may not always be spot-on; feel free to ask it follow-up questions and don’t forget to provide its responses a :thumbsup: or :thumbsdown: so other folks in the Community know if you’re still looking for help on the topic!

I’m not able to find any data sources to answer your question. Could you provide more details about the specific issue or question you have regarding DataHub? If this doesn’t help, please reach out to the DataHub support team for further assistance. :+1: 0 button :-1: 0 button :bulb: Hint: Mention @runllm in the thread for followups.