The previous lesson ended with a dozen YAML datasheets that say who is accountable for each dataset, how it is classified and how long it is kept. It is a good start, but Laura, the analyst, still asks herself the same questions every week: is there already a table with sales by city or do I have to build it? What exactly does the net_amount column mean? Where does this figure come from? Can I trust it? And Íñigo asks his own: if I change this table, which reports do I break?

All of them are answered with metadata: data that describes data. In this lesson we will see what types of metadata exist, how they are organized in a data catalog, how they are collected automatically instead of being written by hand, and what lineage is, the map that shows where each piece of data comes from and where it goes. We will finish with the idea of data contracts and with a decision for DataCorp in proportion to its size.

What metadata is and what types there are

Metadata is any information that describes a piece of data without being the data itself. In a library, the books are the data; the index card with the title, the author, the subject and the shelf is the metadata. Without index cards, the library still has all its books, but nobody can find any of them.

Metadata falls into four types:

Type What it describes Examples for consumption.fact_sales Who produces it
Technical The physical and logical shape of the data Columns and types (net_amount NUMERIC(14,4)), Parquet format, partition month=, path in the bucket The systems, automatically
Business The meaning and the rules "Net sales = amount excluding VAT of the valid orders"; owner Carmen; classification confidential People (owners and stewards)
Operational What has happened to the data Last load at 03:12; 3,790 rows added; duration 4 min; result of the quality checks The processes, automatically
Social (usage) How people use it 14 users query it; 230 queries last week; comment from Laura: "always use with dim_date" The query tools and the users

Two important ideas about this classification:

  • Technical and operational metadata can be collected without human intervention; business metadata cannot. People's effort should be concentrated on what only they know.
  • Social metadata shows what matters. A table that nobody has queried for six months is a candidate for removal; one that 14 people use deserves the best documentation.

The data catalog

A data catalog is an organized, searchable inventory of an organization's datasets, together with their metadata. It is to data what a search engine is to the web.

It solves very specific problems, and all of them occur at DataCorp today:

Problem Symptom What the catalog provides
"Nobody knows what data exists" Each analyst rebuilds in their own spreadsheet what somebody else already did Search by name, description or business term
"I don't know what this column means" The same questions asked again and again to the two people who know Description of each table and column
"I don't know whether I can trust it" Every figure is doubted Owner, date of the last load and quality status in plain view
"I don't know who to ask" Questions get lost Owner and steward on every datasheet
"I don't know whether I'm allowed to use it" Misuse of personal data, or fear of using it Classification and access conditions

A catalog offers at least four functions: inventory (what there is), search (finding it), documentation (understanding it) and context (who is accountable, where it comes from, what quality it has).

A warning before going on: in some engines the technical component that stores the list of tables and their schemas so that queries can be run is also called a "catalog" (or metastore). That is a technical catalog, for machines. The data catalog this lesson deals with is for people, and it is normally fed from the technical one.

Business glossary versus data dictionary

These are two pieces that are often confused and that the catalog brings together:

Business glossary Data dictionary
Describes Business concepts Physical tables and columns
Language That of the business Technical
Example "Net sales: sum of total_amount / 1.21 of the valid orders, by order date" "consumption.fact_sales.net_amount: NUMERIC(14,4), amount of the line excluding VAT"
System-independent Yes: the definition holds even if the platform changes No: it describes a specific implementation
Maintained by The owner and the steward of the domain The data team, largely automatically
Cardinality Dozens of terms Hundreds or thousands of columns

The value lies in linking them: the glossary term "net sales" points to the column that implements it, and the column points to the term that explains its meaning. That way, whoever searches for "net sales" reaches the right table, and whoever comes across net_amount reaches the official definition approved in policy POL-04.

At DataCorp, the glossary lives in the same repository as the datasheets:

# governance/glossary.yaml (excerpt)
- term: net_sales
  name: Net sales
  definition: >
    Sum of total_amount / 1.21 of the orders whose status is neither
    'cancelled' nor 'returned', by order date.
  domain: sales
  owner: [email protected]
  approved: 2026-11-19
  implemented_in:
    - consumption.fact_sales.net_amount
    - consumption.daily_net_sales
  synonyms_to_avoid: [sales, turnover, revenue]

The synonyms_to_avoid field collects the ambiguous words that caused the October dispute: whoever searches for "turnover" will find this term and learn what the correct name is.

Automatic metadata collection

A catalog written by hand is out of date the next day. The rule is: any metadata that a machine can obtain should be obtained by a machine. Catalog tools call this metadata ingestion or discovery, and they do it in two ways:

  • Pull: a process connects periodically to the sources and reads their structure.
  • Push: the data processes themselves report their metadata when they run.

Let's look at two examples of the pull approach.

From a database: information_schema

SQL databases describe their own structure in a standard schema called information_schema. This query returns the technical dictionary of the whole consumption schema:

SELECT
    table_schema     AS schema_name,
    table_name,
    column_name,
    data_type,
    is_nullable      AS nullable,
    ordinal_position AS column_position
FROM information_schema.columns
WHERE table_schema = 'consumption'
ORDER BY table_name, ordinal_position;

information_schema.columns has one row for each column of each table. No business data is queried: only the structure (for example, that consumption.dim_customer.customer_sk is an integer that does not allow nulls).

From a Parquet file

In lesson 02-06 we saw that a Parquet file carries its schema and its statistics in the footer. The following program reads them with the pyarrow library and generates the technical part of a catalog entry:

# governance/collect_metadata.py
from datetime import date

import pyarrow.parquet as pq   # pip install pyarrow
import yaml                    # pip install pyyaml


def extract_technical_metadata(parquet_path: str) -> dict:
    """Reads the footer of a Parquet file and returns its technical metadata."""
    schema = pq.read_schema(parquet_path)     # column names and types
    footer = pq.read_metadata(parquet_path)   # row count, row groups, etc.

    columns = []
    for field in schema:                      # one 'field' per column
        columns.append({
            "name": field.name,
            "type": str(field.type),
            "nullable": field.nullable,
        })

    return {
        "format": "parquet",
        "rows": footer.num_rows,
        "collected": date.today().isoformat(),
        "columns": columns,
    }


if __name__ == "__main__":
    path = "fact_sales/month=2026-10/part-00000.parquet"
    entry = {
        "name": "consumption.fact_sales",
        "technical": extract_technical_metadata(path),
    }
    # sort_keys=False keeps the order; allow_unicode avoids escaping non-ASCII characters
    print(yaml.safe_dump(entry, sort_keys=False, allow_unicode=True))

Explanation:

  • pq.read_schema and pq.read_metadata read only the footer of the file, a few kilobytes, without loading the data. That is why the program takes the same time with a 1 MB file as with a 1 GB one.
  • The loop goes through the schema and stores, for each column, the name, the type (converted to text with str) and whether it allows nulls.
  • yaml.safe_dump converts the dictionary into YAML text, the same format as the datasheets.

The output (abridged) is:

name: consumption.fact_sales
technical:
  format: parquet
  rows: 116250
  collected: '2026-11-18'
  columns:
  - name: line_id
    type: int64
    nullable: false
  - name: net_amount
    type: decimal128(14, 4)
    nullable: true

(The 116,250 rows are consistent with October: 46,500 orders × 2.5 lines on average.)

Combining the automatic and the manual

The datasheet from lesson 03-01 is extended with two new blocks, and each part has a different origin:

# governance/datasheets/consumption.fact_sales.yaml (extended)
name: consumption.fact_sales
owner: [email protected]     # ... rest of the governance fields

# Business block: written by people and reviewed like code
sources: [cleansed.orders, cleansed.order_lines,
          consumption.dim_customer, consumption.dim_product]
descriptions:
  gross_amount: Amount of the line including VAT (quantity x unit_price).
  net_amount: Amount of the line excluding VAT (gross_amount / 1.21).
  order_status: Current status of the order; updated on every load.
glossary_terms: [gross_sales, net_sales, valid_order]

# Technical block: regenerated by the collector on every load. Not edited by hand.
technical:
  format: parquet
  rows: 116250

The separation has a useful consequence: the collector can compare today's schema with yesterday's and warn if a column has appeared, has disappeared or has changed type, or if there is a column without a description.

Data lineage

Data lineage is the record of the path a piece of data follows: which sources it comes from, which transformations it goes through and which destinations it reaches. It answers the question "where does this figure come from?".

Table-level lineage

The simplest level relates datasets to each other. This is the lineage of consumption.fact_sales, from the transactional database to the UC-01 dashboard:

graph LR
    subgraph "Source: PostgreSQL (replica)"
        P["orders"]
        L["order_lines"]
        C["customers"]
        PR["products"]
    end
    subgraph "Raw zone"
        BP["postgres/orders"]
        BL["postgres/order_lines"]
        BC["postgres/customers"]
        BPR["postgres/products"]
    end
    subgraph "Cleansed zone"
        DP["cleansed.orders"]
        DL["cleansed.order_lines"]
        DC["cleansed.customers"]
        DPR["cleansed.products"]
    end
    subgraph "Consumption zone"
        DIMC["dim_customer"]
        DIMP["dim_product"]
        H["fact_sales"]
        V["daily_net_sales"]
    end
    P --> BP --> DP --> H
    L --> BL --> DL --> H
    C --> BC --> DC --> DIMC --> H
    PR --> BPR --> DPR --> DIMP --> H
    H --> V --> CM["Sales dashboard<br/>(UC-01)"]

The diagram can be read in both directions. Backward (upstream): fact_sales depends on four PostgreSQL tables. Forward (downstream): fact_sales, daily_net_sales and a dashboard depend on postgres/orders.

Column-level lineage

The column level details which source columns are involved in each target column and with which transformation:

Column of fact_sales Source columns Transformation
line_id, order_id, quantity order_lines.line_id, .order_id, .quantity Direct copy
date_sk orders.order_date Date converted to the integer YYYYMMDD
customer_sk orders.customer_id Lookup in dim_customer of the version in effect on the order date
product_sk order_lines.product_id Lookup in dim_product
order_status orders.status Copy; updated when the status changes
gross_amount order_lines.quantity, .unit_price quantity × unit_price
net_amount order_lines.quantity, .unit_price quantity × unit_price / 1.21

This level is far more precise and far more expensive to maintain. If products.price is changed, table-level lineage says that fact_sales might be affected; column-level lineage makes it clear that it is not, because the amounts are calculated with order_lines.unit_price (the price at which the item was sold), not with the list price.

Manual lineage is only sustainable at table level and for a few tables. Tools obtain it automatically in two ways: by parsing the SQL of the transformations (from an INSERT INTO b SELECT ... FROM a it follows that b depends on a) or by receiving events that the processes emit when they run.

Impact analysis and root cause analysis

Lineage has two main uses, one in each direction:

Use Direction Question Example at DataCorp
Impact analysis Forward "If I change this, what is affected?" The store team wants to rename orders.status: it affects fact_sales, daily_net_sales and the dashboard
Root cause analysis Backward "This figure is wrong; where did the error originate?" Yesterday's net sales are half the normal figure: fact_sales, cleansed.orders and postgres/orders are reviewed, in that order, until the incomplete load is found

A third use is compliance: knowing which tables a customer's email ends up in is essential to honor their rights over their data (lesson 03-04).

Since lineage is a graph, impact analysis is a traversal. With the sources field of the datasheets, a program of a few lines is enough:

# Table-level lineage: each dataset and the sources it depends on
# (in practice, this dictionary is built by reading the YAML datasheets)
SOURCES = {
    "cleansed.orders": ["raw.postgres/orders"],
    "cleansed.order_lines": ["raw.postgres/order_lines"],
    "consumption.fact_sales": ["cleansed.orders", "cleansed.order_lines",
                               "consumption.dim_customer", "consumption.dim_product"],
    "consumption.daily_net_sales": ["consumption.fact_sales"],
    "dashboard.sales": ["consumption.daily_net_sales"],
}


def affected_by(dataset: str) -> set[str]:
    """Returns all the datasets that depend, directly or indirectly,
    on the given dataset (impact analysis, forward)."""
    affected = set()
    pending = [dataset]
    while pending:
        current = pending.pop()
        for target, sources in SOURCES.items():
            if current in sources and target not in affected:
                affected.add(target)       # it depends on 'current'...
                pending.append(target)     # ...and we must carry on from it
    return affected


print(sorted(affected_by("cleansed.orders")))

The program starts from one dataset, looks for those that have it among their sources, and repeats the search from each of the ones found until none are pending. The affected set prevents the same node from being visited twice. Output:

['consumption.daily_net_sales', 'consumption.fact_sales', 'dashboard.sales']

Active metadata

Traditionally metadata has been passive: documentation that somebody looks up. We speak of active metadata when the metadata is collected continuously and triggers automatic actions on the platform. Some examples:

Metadata Action it triggers
A column is tagged as personal data Masking is applied to it automatically (lesson 03-04)
The retention_months field of a datasheet The storage lifecycle rule is generated
A table fails its quality check The downstream tables, according to the lineage, are flagged with a warning
A table has not been queried for 180 days Its owner is prompted to archive it
The schema of a source changes The owners of the affected datasets are notified

The automatic validation of datasheets in lesson 03-01 was already a first step in this direction: the metadata does not just inform, it prevents an incorrect change.

Catalog and lineage tools

The landscape is broad. This table places the best-known options, without going into how they work:

Tool Type Main features To bear in mind
DataHub Open source (origin: LinkedIn) Catalog, lineage and governance; event-based architecture, highly extensible Deployment with several components; needs to be operated
OpenMetadata Open source Catalog, lineage, glossary and quality built in; simpler architecture Younger project; it also has to be operated
Amundsen Open source (origin: Lyft) Focused on search and discovery Narrower scope and less activity than the previous ones
Apache Atlas Open source (Apache) Governance, classification and lineage, born in the Hadoop ecosystem More natural on Hadoop platforms than outside them
Cloud providers' catalogs Managed service Integrated with each provider's services (AWS Glue Data Catalog, Microsoft Purview, Dataplex on Google Cloud) Little operation, in exchange for vendor lock-in; uneven coverage outside their own cloud
Commercial catalogs Paid product Advanced governance features and approval workflows High license cost; designed for large organizations
OpenLineage Open standard (not a catalog) Defines a common format for lineage events that processes emit and that different tools know how to receive Its usefulness depends on the orchestrator and the engines emitting it

The most relevant piece in the long term is the last one: if the processes emit their lineage in a standard format, changing catalogs does not force you to redo the instrumentation. It is the same reasoning that led to choosing open file formats in ADR-004.

Data contracts

The catalog describes the data as it is. A data contract goes one step further: it is an explicit agreement between whoever produces a dataset and those who consume it about its schema, its meaning and its guarantees. It turns implicit expectations ("the status column has always had those six values") into written, verifiable commitments.

At DataCorp, the clearest case is at the boundary with the transactional database: the store's development team can change a table without knowing that the analytical platform depends on it. A contract prevents that:

# contracts/postgres.orders.yaml
contract: postgres.orders
version: 1.0.0
producer: store development team
consumers: [data platform]

schema:
  - {column: order_id,     type: integer,       nullable: false, unique: true}
  - {column: customer_id,  type: integer,       nullable: false}
  - {column: order_date,   type: timestamp,     nullable: false}
  - {column: status,       type: text,          nullable: false,
     values: [pending, paid, shipped, delivered, cancelled, returned]}
  - {column: total_amount, type: "numeric(10,2)", nullable: false}

guarantees:
  availability: a day's orders are in the replica before 01:00
  breaking_changes: announced 14 days in advance
  compatible_changes: adding columns requires no notice

contact: [email protected]

The contract has three parts: who makes the commitment, what shape the data has and what guarantees are given. A breaking change (removing a column, changing a type, adding a new status) requires publishing a new version and giving notice. Like the datasheets, the contract is a file that a machine can validate: it is enough to compare the actual schema of the table with the declared one. Checking the rules about the content (allowed values, nulls, uniqueness) is the subject of lesson 03-03.

A contract is not a legal document, nor does it need a tool of its own. The essential thing is the conversation it forces producer and consumer to have. You do not need one for every table: they are reserved for the boundaries between teams.

Decision for DataCorp

The temptation is to install DataHub or OpenMetadata. Marta rules it out for now with three arguments: the platform will initially have a few dozen datasets; either of those tools is one more system to deploy, upgrade and watch over, in the hands of two people (RQ-13); and the valuable content, the business metadata, has to be written anyway.

Aspect Phase 1 (first 12 months): catalog as code Phase 2: to be reviewed if...
Inventory YAML datasheets in governance/datasheets/ (ADR-005) The number of datasets exceeds about 100
Technical metadata collect_metadata.py regenerates the technical block on every load There is more than one platform to catalog
Glossary governance/glossary.yaml, linked to the datasheets The stewards need to edit without using the repository
Browsing A static website with a search box, generated from the datasheets on every change Social metadata or approval workflows are required
Lineage At table level, with the sources field; at column level only for the glossary metrics Automatic column-level lineage is needed
Contracts One for each PostgreSQL table that is extracted, agreed with development More producer teams appear

Two precautions keep phase 2 open: the datasheets use a simple format that can be loaded into any catalog, and when the orchestrator is chosen (Module 4), its ability to emit OpenLineage events will be taken into account. No new ADR is written: the decision elaborates on item 4 of ADR-005.

Common Mistakes and Tips

  • Documenting by hand what can be extracted. Schemas written by hand age within days. Reserve human effort for the meaning.
  • Cataloging everything with the same level of detail. Document the consumption tables thoroughly, since those are the ones people use, and leave the intermediate ones with the bare minimum.
  • Descriptions that repeat the name. "order_date: date of the order" adds nothing. A good description clarifies what the name does not say: unit, time zone, whether it includes VAT, when it is updated.
  • A catalog detached from daily work. If updating it means remembering to go to another tool, it will not be updated. Build it into the change process.
  • Confusing the engine's technical catalog with the data catalog. The former lists tables in order to run queries; the latter explains them to people.
  • Column-level lineage for everything from day one. It is expensive. Start with table-level lineage.
  • Contracts that nobody checks. A contract without automatic validation is just a statement of intent.
  • Tip: measure the catalog by its use. If Laura still asks over chat what a column means, the catalog is not doing its job.
  • Tip: when you answer a question about a piece of data, write the answer in the datasheet. The second person with the same question will find it on their own.

Exercises

Exercise 1: Root cause analysis

Write a function sources_of(dataset) that, using the SOURCES dictionary from the lesson, returns all the datasets that the given dataset depends on, directly or indirectly. What does it return for consumption.daily_net_sales?

Exercise 2: Changes to a contract

The development team proposes three changes to the orders table. For each one, state whether it is compatible with the postgres.orders v1.0.0 contract and what would have to be done:

  1. Adding a channel column (web or app).
  2. Adding the status partially_refunded.
  3. Changing total_amount so that it does not include VAT.

Solutions

Exercise 1

def sources_of(dataset: str) -> set[str]:
    """Datasets that 'dataset' depends on (root cause, backward)."""
    found = set()
    pending = [dataset]
    while pending:
        current = pending.pop()
        # .get returns an empty list if 'current' has no sources recorded
        for source in SOURCES.get(current, []):
            if source not in found:
                found.add(source)
                pending.append(source)
    return found

For consumption.daily_net_sales it returns seven datasets: consumption.fact_sales, cleansed.orders, cleansed.order_lines, consumption.dim_customer, consumption.dim_product, raw.postgres/orders and raw.postgres/order_lines. It is simpler than affected_by because the dictionary is already indexed by target: you only need to follow the lists of sources.

Note: the dimensions appear as sources with no sources of their own because the example dictionary does not record them. An incomplete lineage gives incomplete answers without warning; that is why it is best to generate it automatically.

Exercise 2

  1. Compatible. Adding columns does not break existing consumers. Version 1.1.0 of the contract is published with no need for advance notice.
  2. Breaking, even though no type changes: the contract lists the values of status. A new value affects the definition of "valid order" (does it count as a sale?). It requires 14 days' notice, version 2.0.0 and a decision by Carmen, owner of Sales, on how to treat it.
  3. Breaking, and the most dangerous one, because the schema does not change: same name, same type, different meaning. No schema check would detect it, and net sales would end up divided by 1.21 twice. It requires version 2.0.0, notice and, preferably, a new column with a different name instead of changing the meaning of the existing one.

Lesson from item 3: semantic changes are the most damaging. A contract must describe the meaning, not just the shape.

Conclusion

Metadata is the data that describes data, and it is divided into technical, business, operational and social. A data catalog brings it together so that anybody can find a dataset, understand it and know who is accountable for it; it combines a business glossary (concepts) with a data dictionary (tables and columns), linked to each other. Technical metadata must be collected automatically, as we have done with information_schema and with the footer of a Parquet file. Lineage traces the path of each piece of data and enables impact analysis, forward, and root cause analysis, backward. Active metadata turns that information into automatic actions, and data contracts put in writing what a producer guarantees to its consumers. DataCorp will start with a catalog as code (datasheets, glossary, collector and table-level lineage) and will review the adoption of a tool when its scale justifies it.

We now know what data there is, what it means and where it comes from. What is missing is what matters most to those who use it: whether it is correct. The catalog can show that fact_sales was loaded last night, but it does not say whether the amounts add up, whether there are duplicate customers or whether half a day of orders is missing. How to define, measure and improve data quality is the subject of the next lesson.

© Copyright 2026. All rights reserved