Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Enforcing Data Contracts and Lineage in Python

Learn how to enforce data contracts, validate domain-owned data products, and trace dependencies using a reproducible open-source Python implementation.

Enforcing Data Contracts and Lineage in Python

This Python implementation demonstrates how to enforce data contracts and lineage in a publishing system. The example uses four synthetic data products: customer profiles from the Customer domain, order lifecycle records from the Sales domain, and two derived products: business performance metrics and order volume statistics.

The key points are:

1. Producers declare explicit contracts and publication steps, ensuring consumers consume validated data. Each producer has a unique catalog entry that defines the allowed inputs and outputs.

2. Data contracts include more than just schema information. They include contextual information like ownership, allowed consumers, required fields, freshness constraints, and uniqueness rules.

3. Validation is performed on the entire batch of candidate rows before any data is published. The validation rules are enforced for each data contract. If any validation errors are found, a governance error is raised and the batch is rejected.

4. A reproducible example is provided with synthetic data to demonstrate the concepts. The script can be run using Python 3.10 or later. It publishes the four source products, computes the analytics and sales feature products, and generates a report detailing the dependencies and impacted downstream products.

5. The example covers several potential failure scenarios like missing required fields, invalid data types, duplicate identifiers, freshness constraints, and unauthorized access. Each failure is handled appropriately, leaving the previously published file unchanged.

In summary, this example shows how to model and enforce data contracts, quality checks, publication boundaries, and lineage dependencies in a system. It provides a foundation for structuring and validating data products in a way that promotes data integrity, traceability, and dependable publishing.

Rewritten by urgent.news; may contain errors — check the original.

Source: hackernoon.com

Read the original at hackernoon.com →

Report a problem with this story

More in Tech

More from Thursday 26 November →