Ship the SQL
SelectJoin stops at SQL text. How you ship it depends on what already runs SQL for you.
| What runs your SQL | Use | Result |
|---|---|---|
Something that runs .sql files |
selectjoin compile --all --output |
One SELECT per model |
| The same, but it should create objects | selectjoin compile --all --materialize --output |
One CREATE VIEW, CREATE TABLE AS, or MERGE per model |
| dbt | selectjoin export dbt |
dbt models with ref() and source() |
| Airflow | selectjoin export airflow |
A DAG with one task per model |
| A person | selectjoin compile NAME |
The query, printed to the terminal |
Write SQL files
Section titled “Write SQL files”selectjoin compile --all --output target/sqlWrote target/sql/int_order_customer_features.sqlWrote target/sql/mart_customer_revenue.sqlEach file is a complete, self-contained query: every upstream model is included as a CTE, so a file runs on its own.
--layer martswrites only one layer.--dialect postgresrenders another SQL dialect.- Existing files are never replaced unless you pass
--force.
Write statements that create objects
Section titled “Write statements that create objects”selectjoin compile --all --materialize --output target/sqlA model with materialization="view" becomes CREATE VIEW ... AS, a table becomes CREATE TABLE ... AS, and an incremental model becomes a MERGE over its date window.
With --all or --layer, sources and ephemeral models are skipped, because neither has an object to create. Asking for one source by name is an error.
Choosing between files and an export
Section titled “Choosing between files and an export”Compiled files are simplest, but every model recomputes its upstream models, because each file stands alone. That is fine for a handful of marts.
When models should build on each other’s tables, use an export. The dbt and Airflow exports write each model so it reads the tables built before it, and they carry the dependency order with them.
Do it in CI
Section titled “Do it in CI”A typical pipeline step validates, blocks breaking changes, then writes the output:
selectjoin checkselectjoin diff --against origin/mainselectjoin compile --all --materialize --output target/sql --forceNone of these commands need warehouse credentials.