Build and manage data products
How to add sources, domains, data products, resources and Gold models to a project, how their names line up, and how to check and deploy a change. For a guided first walkthrough of the same steps, follow the tutorial.
Run every command from the project directory, on a deployed local platform.
The examples use the source marketing_platform, the domain marketing and
the product campaign_performance.
How a project is laid out
Section titled “How a project is laid out”Ownership follows the medallion layer:
| Layer | Owned by | Directory | Built by |
|---|---|---|---|
| Bronze | A source | lakehouse_code/bronze/<source>/ |
dlt |
| Silver | A domain | lakehouse_code/silver/<domain>/ |
Floe |
| Gold | A data product | lakehouse_code/gold/models/<product>/ |
dbt-trino |
| Dashboards | A dashboard | lakehouse_code/dashboards/superset/<dashboard>/ |
Superset |
lakehouse_code/governance.yml names the domains and, nested under each, its
products; each source has a source.yaml, and each dashboard is a bundle directory. OpenLakeForge
derives every platform name from these, so you never create catalog namespaces
or edit Terraform to register a product:
| Derived name | Example | Shared by |
|---|---|---|
Silver namespace <domain>_silver |
marketing_silver |
Every product of the domain |
Gold namespace <product>_gold |
campaign_performance_gold |
The product only |
Dagster job <product>_pipeline |
campaign_performance_pipeline |
The product only |
Every identifier matches ^[a-z][a-z0-9_]*$, so campaign_performance, not
campaign-performance. A product id is unique across the whole lakehouse.
Field-by-field rules are in the descriptor reference.
Add a source
Section titled “Add a source”olf source new marketing_platform --resource campaignsRepeat --resource for each table-like input. The command writes
bronze/marketing_platform/ with a source.yaml, a dlt loader under dlt/
and one placeholder CSV per resource under examples/. It validates its result
first and writes nothing if validation fails.
Replace each placeholder CSV with your real columns before you create a domain or product that reads it: the Silver contract’s columns are inferred from that file at creation time.
Add a domain
Section titled “Add a domain”olf domain new marketing --input marketing_platform/campaignsA domain owns a set of Silver tables. Each --input <source>/<resource>
becomes a Silver table of the same name, validated by its own entity file,
silver/marketing/contracts/<resource>.yml. The domain’s
silver/marketing/domain.yml sets the Iceberg namespace, the rejected-rows
path and the policy for all of them. An entity declares column types and a primary key;
every column starts as nullable: false, so loosen a column by hand when a
value may be empty. Floe validation
describes the layout.
olf product new also creates the domain when its --input names a domain
that does not exist yet, so this step is optional.
Add a data product
Section titled “Add a data product”olf product new marketing/campaign_performance \ --silver-input campaigns \ --gold-table mart_campaign_performance| Option | Use |
|---|---|
--silver-input <table> |
A Silver table the domain already has. Repeatable. |
--input <source>/<resource> |
A Bronze resource to add to the domain’s Silver and read. Creates the domain if needed. Repeatable. |
--gold-table <mart> |
A Gold mart the product produces. Repeatable, at least one. |
--with-report |
Also scaffold a draft Superset report; see Dashboards as code. |
It creates the product’s folder gold/models/campaign_performance/ in the
Gold dbt project and registers the product in governance.yml. It also adds the product’s
+group block to gold/dbt_project.yml and declares any Silver table the
domain’s gold/models/_sources/<domain>.yml lacks; the first product creates
the project itself. It writes no Dagster code: pipelines/definitions.py
builds a job for every product in governance.yml, and
pipelines/products.py needs an entry only to change a product’s
cadence or inputs.
The generated model mart_campaign_performance.sql selects everything from
the first Silver input. Replace it with your SQL, reading Silver through
{{ source('<domain>', '<table>') }}, and describe and test it in the
product’s schema.yml; dbt runs the tests in the same build, so a failing
test fails the run. Do not hard-code Trino hosts or catalogs: OpenLakeForge
renders the dbt profile for each stage.
Add a resource to an existing source
Section titled “Add a resource to an existing source”-
Add it under
resourcesinbronze/marketing_platform/source.yaml. -
Add its data as
examples/<resource>.csv. -
Add its name to the entity tuple in
dlt/marketing_platform.py:MARKETING_PLATFORM_ENTITIES = ("campaigns", "ad_groups") -
Carry it into Silver. The simplest way is a new product that reads it, which also adds the Silver table and its Floe entity:
Terminal window olf product new marketing/ad_group_report \--input marketing_platform/ad_groups --gold-table mart_ad_groups
To let an existing product read the resource instead, make these edits by hand:
| File | Add |
|---|---|
silver/marketing/contracts/ad_groups.yml |
An entity file, copied from an existing one, with source: { ref: marketing_platform, resource: ad_groups } |
gold/models/_sources/marketing.yml |
- name: ad_groups under the marketing source |
gold/models/<product>/<mart>.sql |
A read of {{ source('marketing', 'ad_groups') }} |
Add a Gold model to an existing product
Section titled “Add a Gold model to an existing product”-
Add
gold/models/<product>/<mart>.sqland describe it in the product’sschema.yml. No descriptor lists it: its folder puts it in<product>_gold, and a table there belongs to the product.The product’s Dagster job picks the model up from the dbt project; nothing in
pipelines/lists it.
A product’s models are private to it: gold/dbt_project.yml sets
+access: private, and each product is a dbt group. To let another product
ref() a mart, set access: public on that model in its schema.yml:
models: - name: mart_campaign_performance access: publicA ref() to a model that is not public fails to parse. The reading product’s
job uses the model as it is and never rebuilds it, so its Dagster asset is an
upstream dependency of the reading product’s assets.
Run the owning product first. The reading product’s dbt step fails, naming the
owner, when the owner has never built the model on that stage or has a run
queued or running, instead of reading a stale or half-replaced set of tables.
Schedule the owner’s cadence before its readers’ in pipelines/products.py.
The e2e runner launches the products owners first.
The guard checks that the model was built at some point, not that it is fresh.
It runs once, when the reading product’s dbt step starts: a producer in another domain
that starts later is not held back (runs of one domain already queue one at a time),
so keep the owner’s schedule ahead of its readers’.
olf check contracts lists each dependency (product_dependencies) and
refuses a ref() to a model that is not access: public, or two products that
read each other.
The example sales_core product is built for this: it holds the sales domain’s
row-level fact (fct_order_lines) and conformed dimensions (dim_account,
dim_product, dim_channel, dim_promotion), all access: public with every
model and column described and its keys tested (unique and not_null, plus
relationships from each fact key to its dimension). Marts aggregate such
models; business filters such as “fulfilled orders only” belong to the metric
that uses them, not to the fact. order_revenue, customer_health and
inventory_reliability read sales_core.
Roles and dependencies in OpenMetadata
Section titled “Roles and dependencies in OpenMetadata”A deploy publishes the Gold graph to OpenMetadata, so a person or an agent can tell a conformed fact from a presentation mart and see which products a product builds on:
-
Role. Every Gold table carries one tag of the
GoldRoleclassification, which OpenLakeForge creates:Factforfct_,Dimensionfordim_,Martformart_. To give a model another name, set its role in itsschema.ymlentry, asFact,DimensionorMartin any letter case:models:- name: order_lines_widemeta:openlakeforge:role: factA declared role wins over the prefix.
olf check contractsfails (gold_roles) on a model that resolves neither. Tags of other classifications, and glossary terms, are left alone. -
Dependencies. The
ref()graph above becomesconsumesFromon the consuming data product, soorder_revenuelistssales_core. A deploy adds a missing edge and never removes one. The consumed tables are not attached to the consuming product: it holds only the tables in its own<product>_goldschema, facts and dimensions included.
olf infra openmetadata drift reports a dependency dropped from Git while
OpenMetadata still holds it, a missing edge, and a table without its role tag
(Metadata ownership).
gold/dbt_project.yml sets +persist_docs for every Gold model, so the
descriptions in schema.yml are written as table and column comments.
Keep one model’s reads to about 150 tables or fewer. Trino counts about two
stages per table a query reads and stops at max_stage_count (300 in every
query.size, see
the deployment profile) with
QUERY_HAS_TOO_MANY_STAGES. A union over a whole domain should be split into
staging models.
Add semantic metrics
Section titled “Add semantic metrics”Describe a product’s business metrics, keys and relationships as an Apache
Ossie model in lakehouse_code/semantic/<product>/<name>.ossie.yaml. The
datasets point at the product’s Gold facts and dimensions, and every key and
relationship must be backed by a dbt unique or relationships test in the
product’s schema.yml.
uv run --project tools/olf --locked olf check contractsThe semantic_models check names each broken rule with its file and line. The
supported version, the subset and the rules are in
Semantic models reference.
Link a glossary term to a product and a column
Section titled “Link a glossary term to a product and a column”Business terms live in lakehouse_code/glossaries/<name>.yml; see the
Glossary reference for the fields.
Link a term by its <glossary>.<Term> reference.
-
To the product, in
governance.yml:products:- id: order_revenuedisplayName: Sales Order RevenueglossaryTerms: [sales.NetRevenue, sales.GrossRevenue] -
To the column that holds the term, in the product’s
schema.yml:columns:- name: net_amountmeta:openlakeforge:glossaryTerms: [sales.NetRevenue]Put it on a fact or dimension column (
fct_,dim_), not on amart_column;olf check contractswarns about the latter. -
Check the references resolve:
Terminal window olf check contractsA reference to a term that no glossary declares fails the check and names the file and path to fix.
Where the terms appear in OpenMetadata
Section titled “Where the terms appear in OpenMetadata”olf infra openmetadata deploy-metadata (part of olf infra deploy)
publishes each glossary and its terms first, then attaches them:
| Git | OpenMetadata |
|---|---|
glossaries/<name>.yml |
Glossary <name>, with its terms (description, synonyms, related terms, references, status, owner) |
glossaryTerms on a product or domain |
The glossary tag on that data product or domain |
meta.openlakeforge.glossaryTerms on a column |
The glossary tag on that column of the stage’s own table, for example <service>.lakehouse_dev.sales_core_gold.fct_order_lines.net_amount |
Glossaries and terms OLF publishes carry the olfManaged property. A repeat
deploy of the same revision writes nothing. OLF never deletes: a term removed
from Git stays in OpenMetadata and the deploy warns about it. A glossary, term
or tag a person created under another name is left alone; one created by hand
under the same name as a Git glossary or term is adopted, marked olfManaged
and kept in step with Git on the fields Git declares. A column the Trino crawl has not
produced yet is reported as pending and tagged on the first deploy after the
crawl; OLF never creates a column for it.
Remove a product
Section titled “Remove a product”Delete its entry from governance.yml, its gold/models/<product>/ folder,
its block in gold/dbt_project.yml and its entry in pipelines/products.py, if
it has one. The code location refuses an entry for a product governance.yml
does not declare, so a leftover entry fails loudly instead of lingering.
Renaming a source, domain, product or table changes the derived namespaces,
so on a deployed stage treat it as a data migration, not an edit.
displayName, description and the business fields (owner, tier,
lifecycle and the others in
the governance.yml reference)
are metadata only.
olf infra deploy publishes owner, experts, reviewers, tier,
classification, lifecycle and termsOfUse to OpenMetadata: owners and
experts on the domain and data product pages, a Tier and a DataSensitivity tag
on the product and on its Gold tables, and the lifecycle and terms of use as
the custom properties olfLifecycle and olfTermsOfUse. An owner is an
existing OpenMetadata user or team of type Group, and experts are users;
create them in OpenMetadata or your identity provider first. On the local
stack the demo project seeds its own: sales-analytics owns Sales,
supply-chain-ops owns Supply Chain, and demo-analyst and
demo-data-engineer are the experts and reviewers. That seeding is demo setup
read from lakehouse_code/local-demo-teams.yml and never runs for another
provider
(details).
classification only labels data: it does not change who can read a table.
The descriptors reference
lists every field.
A product can also declare how fresh it promises to be, with an sla block.
The deploy publishes it as the data product’s native SLA and keeps the fields
OpenMetadata has no place for in the olfFreshnessPolicy custom property. It
is a promise: GET /stages/{stage}/sla reports whether the stage observed the
product keeping it, see
Product SLA compliance.
See Product SLA for the fields.
To record who owns a product and how critical it is, set them on the product
and run the strict check, which fails for a product that resolves no owner,
tier or lifecycle:
olf check contracts --strictValidate and deploy
Section titled “Validate and deploy”| Command | Checks |
|---|---|
olf check contracts |
Each descriptor against its schema: identifiers, duplicates, a domain or product without its directory; each Floe domain writes its own <domain>_silver namespace |
olf check project-code |
The whole inventory loads in Dagster, including references between descriptors |
olf check dbt |
Every product’s dbt project parses and compiles, and its models and sources sit in the schemas the descriptors name. Incremental models are parsed (refs, sources, Jinja) but not compiled: is_incremental() needs a warehouse connection, so their rendered SQL is not checked |
Then deploy only the artifacts phase, which covers everything derived from
lakehouse_code/:
olf infra deploy --provider local --phase artifactsIt reconciles the catalog namespaces, builds the project-code image and restarts Dagster’s code location.
Python dependencies
Section titled “Python dependencies”A project that needs a Python package (an API client, a dlt source) lists it in
lakehouse_code/requirements.txt, with plain pins or ranges. The image installs the file in its own
layer after the platform dependencies, constrained to their exact versions, so a project cannot change
a platform pin. olf check project-code and the image build resolve the file against those pins and
fail on a conflict. Unlike the platform lock, this layer is not hash-verified. Without the file the
image is unchanged.
Check it worked
Section titled “Check it worked”Launch campaign_performance_pipeline in Dagster, then query the mart:
olf infra query "SELECT * FROM campaign_performance_gold.mart_campaign_performance"olf infra e2e run --env local --suite full also covers the new product, because it
discovers products from governance.yml.
Synced from openlakeforge @ v0.7.5-beta.1 (8a7bf72), docs/guides/data-products.md.