Skip to content

Choose where to start

Install SelectJoin first. Then pick the path that matches what you have. Each one ends with a project that passes selectjoin check.

You want to Start with Time
See what it does The layered example 5 minutes
Model your own tables A minimal project 20 minutes
Add to a dbt project A dbt package 20 minutes
  1. Create the example: eleven sources and models, from raw tables to a revenue mart.

    Terminal window
    selectjoin init my_project --template layers
    cd my_project
  2. Look at what is in it, then compile the mart.

    Terminal window
    selectjoin list
    selectjoin compile mart_customer_revenue
  3. Open the local explorer to read each model next to its SQL and follow its lineage.

    Terminal window
    selectjoin serve

You can also browse the same project in the online demo without installing anything.

  1. Create a minimal project.

    Terminal window
    selectjoin init my_project
    cd my_project

    It contains one example source, sources/orders.py, which reads its columns from metadata.json, and one staging model built on it.

  2. Replace the example with one of your tables. Declare the columns you need and their types:

    sources/orders.py
    from selectjoin import select, source, table
    @source(name="orders")
    def build():
    raw = table("raw.orders", schema={
    "order_id": "BIGINT",
    "status": "VARCHAR",
    "amount": "DECIMAL(18, 2)",
    })
    return select(raw.order_id, raw.status, raw.amount).from_(raw)

    The schema is a contract you write. To generate it from your warehouse’s metadata instead, see metadata discovery queries.

  3. Scaffold a model of your own on top of the staging model.

    Terminal window
    selectjoin new order_totals --layer marts --from stg_orders --grain order_id

    This creates models/marts/mart_order_totals.py with a starting query that selects every column.

  4. Edit the query, then validate and compile.

    Terminal window
    selectjoin check
    selectjoin compile mart_order_totals
  1. Make sure dbt has written its manifest. Any of dbt parse, dbt compile, or dbt build does.

  2. Create a minimal project next to the dbt project and declare it as a package in selectjoin.toml:

    [packages.analytics]
    type = "dbt"
    manifest = "../analytics/target/manifest.json"
  3. List what was imported. Every dbt model appears as analytics.<model>.

    Terminal window
    selectjoin list
  4. Write a model that references one with ref("analytics.<model>"), then check it.

    Terminal window
    selectjoin check
  5. When it is ready, export it back into the dbt project.

    Terminal window
    selectjoin export dbt --output ../analytics

See Use with dbt for how column types are found and what is exported.