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 |
Explore the layered example
Section titled “Explore the layered example”-
Create the example: eleven sources and models, from raw tables to a revenue mart.
Terminal window selectjoin init my_project --template layerscd my_project -
Look at what is in it, then compile the mart.
Terminal window selectjoin listselectjoin compile mart_customer_revenue -
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.
Start on your own tables
Section titled “Start on your own tables”-
Create a minimal project.
Terminal window selectjoin init my_projectcd my_projectIt contains one example source,
sources/orders.py, which reads its columns frommetadata.json, and one staging model built on it. -
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.
-
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_idThis creates
models/marts/mart_order_totals.pywith a starting query that selects every column. -
Edit the query, then validate and compile.
Terminal window selectjoin checkselectjoin compile mart_order_totals
Start from a dbt project
Section titled “Start from a dbt project”-
Make sure dbt has written its manifest. Any of
dbt parse,dbt compile, ordbt builddoes. -
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" -
List what was imported. Every dbt model appears as
analytics.<model>.Terminal window selectjoin list -
Write a model that references one with
ref("analytics.<model>"), then check it.Terminal window selectjoin check -
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.