Skip to content

Ingest a source

View as Markdownllms.txt

This lesson adds a new source to the project with olf source new, gives it data, and explains the dlt loader that lands that data in Bronze. The source is a marketing platform that exports campaign performance as CSV.

You will scaffold a Bronze source and give it real data, in about 10 minutes.

Start from the project of lesson 1: deployed, with the three demo data products. Run every command from the project directory.

Your code lives under lakehouse_code/, and each medallion layer has its own owner (see ADR 0004):

Layer Aligned to Directory
Bronze A source lakehouse_code/bronze/<source>/
Silver A domain lakehouse_code/silver/<domain>/
Gold A data product lakehouse_code/gold/models/<product>/

Across the next lessons you add the source marketing_platform, the domain marketing and the product campaign_performance. OpenLakeForge derives every platform name from those three: the Silver namespace marketing_silver, the Gold namespace campaign_performance_gold and the Dagster job campaign_performance_pipeline. You never create these by hand and you never edit Terraform to register a product.

Terminal window
olf source new marketing_platform --resource campaigns
Created source 'marketing_platform' with 1 resource(s): campaigns.

The command validates its result before it writes anything, and writes nothing if validation fails. It creates:

lakehouse_code/bronze/marketing_platform/
├── source.yaml
├── README.md
├── examples/
│ └── campaigns.csv
└── dlt/
├── __init__.py
└── marketing_platform.py

source.yaml is the logical description of the source:

apiVersion: openlakeforge.io/v1beta1
kind: Source
name: marketing_platform
displayName: "Marketing Platform"
description: "Marketing Platform source system."
status: planned
resources:
- name: campaigns
description: "Raw CSV campaigns."

It lists the resources the source exposes and never names Polaris, Glue, S3 or any other provider: OpenLakeForge derives the physical names from it. Its name must match its directory.

The scaffold wrote a placeholder file with a single column. Replace it with campaign data:

Terminal window
cat > lakehouse_code/bronze/marketing_platform/examples/campaigns.csv <<'CSV'
campaign_id,campaign_date,channel,spend,conversions
cmp_001,2026-08-01,search,120.50,18
cmp_002,2026-08-01,social,80.00,9
cmp_003,2026-08-02,search,150.00,24
cmp_004,2026-08-02,email,30.00,12
cmp_005,2026-08-03,social,95.50,11
CSV

Do this before the next lesson: the validation contract for Silver is inferred from this file when you create the domain.

dlt/marketing_platform.py is the Bronze loader. It reads each resource’s CSV from examples/ through dlt, writes it to the Bronze bucket under the marketing_platform prefix, and returns the row count, the bronze_uri and the source_file to Dagster, which shows them on the asset. Its core is one call:

return load_entities_to_bronze(
entities=entities,
raw_dir=raw_dir or _RAW_DIR,
bronze_prefix=_BRONZE_PREFIX,
)

Loading is keyed by source, so every product that needs marketing_platform.campaigns calls this one loader. Nothing loads yet: Dagster runs the loader as the first step of a product job, which you create in lesson 4.

Terminal window
olf check contracts

It validates lakehouse_code/governance.yml and every source.yaml against the project schemas. It prints one [PASS] line per check, including:

[PASS] descriptor_schema_conformance: 4 descriptor(s) validated
  • olf source new scaffolds a source-owned Bronze package: a descriptor, a dlt loader and example data.
  • Descriptors stay provider-neutral; OpenLakeForge derives physical names.
  • Bronze fills when a product job runs.

Validate into Silver: declare what a valid row looks like.


Synced from openlakeforge @ v0.7.5-beta.1 (8a7bf72), docs/tutorial/02-ingest-a-source.md.