Blueprints Blog Contact About

sources.sql

No connectors. Just queries.

Sources — no connectors. Just queries.

Phase: Post-catalog | Order: 7 | Required: No

Query external data directly from your models.

No connectors. No ingestion tools. No sync jobs. Just attach a database and use it in SQL.

Use sources when your data already exists somewhere else:

  • Application databases (PostgreSQL, MySQL)
  • Operational systems
  • Existing warehouses

You don’t need to copy the data first.

Mental Model

External data is just another table. Once attached, you query it like any other model.

Sources are read at query time — not synced.

Examples

PostgreSQL

-- Attach a PostgreSQL database (read-only)
-- Requires: postgres in extensions.sql, credentials in secrets.sql
ATTACH 'postgresql://user:pass@host:5432/warehouse' AS warehouse (READ_ONLY);

MySQL

-- Attach a MySQL database (read-only)
-- Requires: mysql in extensions.sql, credentials in secrets.sql
ATTACH 'mysql:host=db.example.com port=3306 database=app' AS app_db (READ_ONLY);

Usage in Models

Once attached, external tables behave like local tables. No ingestion step required.

-- models/raw/customers.sql
-- @kind: table
SELECT
    customer_id,
    name,
    email,
    created_at
FROM warehouse.public.customers
WHERE active = true
-- models/raw/products.sql
-- @kind: table
SELECT *
FROM app_db.products

Files

For files (Parquet, CSV, JSON), no setup is required. Read them directly in your models:

SELECT * FROM read_parquet('data/*.parquet')
SELECT * FROM read_csv('data/events.csv')
SELECT * FROM read_json('s3://bucket/api-dump.json')