render
Render the final SQL for a model with all templates and macros expanded.
This is useful for debugging template issues and seeing the exact SQL that will be executed.
Output adapts to environment:
- Terminal: Plain SQL (suitable for syntax highlighting)
- Piped/Scripted: Markdown with code block
Usage
bash
leapsql render <model>Global Options
| Option | Short | Default | Description |
|---|---|---|---|
--config | config file (default: ./leapsql.yaml) | ||
--database | Path to DuckDB database (empty for in-memory) | ||
--env | Environment name | ||
--macros-dir | Path to macros directory | ||
--models-dir | Path to models directory | ||
--output | -o | Output format (auto|text|markdown|json) | |
--project-dir | -C | Project root directory (auto-detected from models-dir or config file location) | |
--seeds-dir | Path to seeds directory | ||
--state | Path to state database | ||
--target | -t | Target environment to use (e.g., dev, staging, prod) | |
--verbose | -v | false | Verbose output |
Examples
bash
# Render a model's SQL
leapsql render staging.stg_customers
# Render and save to file
leapsql render staging.stg_customers > rendered.sql
# Render as JSON
leapsql render staging.stg_customers --output json
# Render as Markdown (with code block)
leapsql render staging.stg_customers --output markdown