Pushing Data Quality Check Results to DataHub using Python SDK or REST API through examples

Original Slack Thread

Hello, team! Anyone has an example for pushing data quality check results (assertions) to DataHub using the Python SDK or the REST API?

Hi <@U04QE11EXDE>,

yes we do so via the Python SDK. What aspects are you interested about?
I can share some examples but this requires me to prepare the code, so I’d like to make sure to provide you with something useful for you :slightly_smiling_face:

<@U049WUH4155> I’m not using Great Expectations, I built a data quality system integrated to my Data Lake and after running the quality checks, I want to publish the results to DataHub, considering that I already have the quality check results ready and I just need to build the assertion objects and publish them to Datahub

So the only part I would like some example is on the correct way of building and publishing the results to Datahub

Interesting, that’s exactly what we did as well
I’m happy to provide you with some examples

In general you need to send. three kind of objects to the API:
• Assertion Info
• Assertion Platform MCP
• Assertion Result
To send the assertion info the following code is required:

The `info` passed as aspect here is an instance of `<http://datahub.metadata.com|datahub.metadata.com>.linkedin.pegasus2avro.assertion.AssertionInfo`
How this should be created highly depends on the type of assertions you want to generate, so feel free to ask for more details.

Secondly, you can publish the platform assertion mapping as follows:
```assertion_platform_mcp = MetadataChangeProposalWrapper(
And finally the result of the assertion:
``` assertion_result_mcp = MetadataChangeProposalWrapper(
Here `result` is an instance of `<http://datahub.metadata.com|datahub.metadata.com>.linkedin.pegasus2avro.assertion.AssertionRunEvent` and can look like the following:
``` AssertionRunEvent(
            timestampMillis=int(round(time.time() * 1000)),
                type=AssertionResultType.SUCCESS if assertion_result.is_success else AssertionResultType.FAILURE,
                nativeResults={"observed_value": assertion_result.observed_value},
I'm happy to go more into detail if required :slightly_smiling_face: