dbt analyses and operations are specialized mechanisms used for ad hoc queries and administrative tasks outside the main model dependency graph. Analyses compile SQL queries using Jinja without materializing tables in the warehouse, while dbt run-operation executes standalone macros from the command line for maintenance and administrative tasks.
Ad hoc queries in the analyses directory
The analyses/ folder is designed for analytical queries that need dbt compilation capabilities but should never materialize as permanent warehouse objects:
- Analysts write standard SQL files using ref and source macros to take advantage of version control and lineage.
- When you execute dbt compile, dbt resolves all Jinja expressions and writes the compiled SQL into target/compiled/my_project/analyses/.
- Standard commands like dbt run and dbt build completely ignore files in analyses/. They never create tables, views, or DAG nodes in your warehouse.
This makes the folder suitable for quarterly audit queries, one-off executive data pulls, and exploratory SQL models that you want version-controlled without cluttering the production DAG.
Administrative tasks with run-operation
The dbt run-operation command executes a named Jinja macro directly from the command line without compiling or running models:
dbt run-operation grant_access_to_analyst --args '{role: reporting_analyst}'Common administrative uses include:
- Granting table permissions and configuring database roles across environments.
- Vacuuming, optimizing, or cloning tables in Snowflake or Databricks.
- Dropping stale development schemas and cleaning up old pull request sandbox tables.
- Running database health checks and stage unloading operations.
Operations execute arbitrary SQL statements via the database adapter, making them a lightweight alternative to external Python maintenance scripts.
Key differences from regular models
Neither analyses nor operations appear as nodes in the production DAG:
- Models represent persistent business datasets and participate directly in lineage graphs, testing suites, and docs generation.
- Analyses provide compiled exploratory SQL for manual inspection or one-time execution in query consoles.
- Operations run transactional maintenance procedures independently of model dependencies.
Separating administrative and exploratory tasks from model pipelines keeps your production DAG focused exclusively on core data transformations.