Skip to content

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
Terminal window
selectjoin compile --all --output target/sql
Wrote target/sql/int_order_customer_features.sql
Wrote target/sql/mart_customer_revenue.sql

Each file is a complete, self-contained query: every upstream model is included as a CTE, so a file runs on its own.

  • --layer marts writes only one layer.
  • --dialect postgres renders another SQL dialect.
  • Existing files are never replaced unless you pass --force.
Terminal window
selectjoin compile --all --materialize --output target/sql

A 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.

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.

A typical pipeline step validates, blocks breaking changes, then writes the output:

Terminal window
selectjoin check
selectjoin diff --against origin/main
selectjoin compile --all --materialize --output target/sql --force

None of these commands need warehouse credentials.