Skip to content

Validate into Silver

View as Markdownllms.txt

This lesson creates the marketing domain with olf domain new, which writes the Floe contract that turns the Bronze CSV into a validated Silver Iceberg table. It explains what the contract checks and where rows that fail it go.

You will create a domain and read its validation contract, in about 10 minutes.

Start from the project of lesson 2: the marketing_platform source exists and campaigns.csv holds the five campaign rows.

Terminal window
olf domain new marketing --input marketing_platform/campaigns
Created domain 'marketing' with 1 Silver table(s): campaigns.
Domain 'marketing' has no products yet; run `olf product new marketing/<product>` to add one.

A domain groups the Silver tables a business area owns. --input <source>/<resource> names a Bronze resource to validate into one of them. The command adds the domain to lakehouse_code/governance.yml and creates a Floe entity for the Silver table campaigns, read from marketing_platform/campaigns:

lakehouse_code/silver/marketing/
├── __init__.py
├── README.md
├── domain.yml
└── contracts/
└── campaigns.yml

It also declares marketing_platform in lakehouse_code/silver/sources.yml, the named Bronze sources every domain’s entities read from.

The Floe contract of a domain is split in two. domain.yml holds what every entity of the domain shares:

name: "marketing"
entities: "contracts/*.yml"
defaults:
incremental_mode: "none"
sink:
write_mode: "overwrite"
accepted:
format: "iceberg"
path: "marketing/{{entity.name}}"
storage: "lakehouse_silver"
iceberg: { catalog: "iceberg_catalog", namespace: "marketing_silver" }
rejected: { format: "csv", path: "floe/rejected/marketing/{{entity.name}}", storage: "lakehouse_silver" }
policy: { severity: "reject" }
schema:
normalize_columns: { enabled: true, strategy: "snake_case" }

Each file in contracts/ is one entity. campaigns.yml names its Bronze input and the columns inferred from the CSV you wrote in lesson 2:

name: "campaigns"
source: { ref: "marketing_platform", resource: "campaigns" }
schema:
primary_key: ["campaign_id"]
columns:
- { name: "campaign_id", type: "string", nullable: false }
- { name: "campaign_date", type: "date", nullable: false }
- { name: "channel", type: "string", nullable: false }
- { name: "spend", type: "number", nullable: false }
- { name: "conversions", type: "integer", nullable: false }

Four parts matter:

  • Source and cast mode. ref: "marketing_platform" points at the source in sources.yml, which reads the CSV dlt wrote to Bronze and casts each value to its column type strictly.
  • Accepted sink. Rows that satisfy the contract are written to the Iceberg table marketing_silver.campaigns. The namespace is named after the domain, not a product: every marketing product shares it.
  • Rejected sink. With severity: "reject", a row that breaks the contract goes to the CSV quarantine path floe/rejected/marketing/campaigns in the Silver bucket instead of into Silver. The run still succeeds: Floe reports it as a run with rejected rows, which is not a technical failure.
  • Columns. Every column is nullable: false, because the scaffold cannot know which are optional. Loosen a column by hand when a value may be empty.
Terminal window
olf check contracts

It checks that each domain writes its own <domain>_silver namespace through the logical catalog. Among its lines:

[PASS] floe_contract_structure: 19 Floe domain and entity file(s) validated
  • olf domain new declares the Silver namespace and writes its Floe contract in one step – domain defaults plus one file per entity – inferring column types from the example CSV. The next deploy creates the namespace in the catalog.
  • Rows that satisfy the contract reach marketing_silver.campaigns; rows that do not are quarantined, not dropped and not mixed into Silver.
  • Silver is owned by the domain; products consume it.

Model Gold with dbt: build a business mart on top of Silver.


Synced from openlakeforge @ v0.6.0-alpha.3 (882b426), docs/tutorial/03-validate-into-silver.md.