Skip to main content
Bolt schedules run dbt™ commands, but sometimes you need to execute plain SQL against your data warehouse as part of a job: creating a table, granting permissions, or running any other DDL or DML statement. The dbt™ run-operation command lets you do this by wrapping your SQL in a macro and running it like any other schedule command. This works with any warehouse connected to Paradime, such as Snowflake, BigQuery, Databricks, or Redshift. The statement runs through your dbt™ connection, so anything the warehouse role or service account behind your connection can execute, the operation can execute.

Prerequisites

  • A dbt™ project connected to your Paradime workspace
  • A data warehouse connection configured for your scheduler environment
  • Permissions on the warehouse role or service account used by your connection to run the statements you need

Create and run a SQL operation

1

Create a macro that wraps your SQL

In your dbt™ project, add a macro that defines the SQL and executes it with run_query():
macros/create_customer_snapshot.sql
The SQL can be any statement your warehouse allows: CREATE OR REPLACE, GRANT, ALTER, DELETE, or warehouse-specific commands like Snowflake’s ALTER PIPE ... REFRESH. The log() call prints a confirmation in the run logs.
2

Test the macro from the Code IDE

Before scheduling, run the operation from a terminal in the Code IDE to confirm it works:
The statement executes against the warehouse connection of your current environment.
3

Add the command to a Bolt schedule

Create a schedule with the Standard schedule type. Deferred and Turbo CI only apply to state-aware dbt™ builds, so a plain SQL operation always uses Standard.In the Commands section, add:
You can run the operation on its own schedule or add it before or after other dbt™ commands in an existing schedule. Commands run in order, so an operation placed after dbt build only executes when the build succeeds.

Pass arguments to your operation

Macros accept arguments, so one macro can serve multiple schedules. Pass values with the --args flag as a YAML string:
macros/grant_select_on_schema.sql
run_query() executes SQL whenever the macro is invoked, including during dbt compile and dbt docs generate if the macro is called from a model or hook. Macros invoked only via dbt run-operation are not affected. If you reference the macro elsewhere, guard it so the SQL runs only when intended:
If your statement is a CREATE OR REPLACE TABLE ... AS SELECT, consider making it a dbt™ model with a table materialization instead. You get lineage, testing, and documentation for free. Reserve run-operation for statements that do not fit the model workflow, such as grants, permissions, and warehouse-specific objects like pipes, stages, and tasks.

Hooks and operational tasks

More run-operation examples, including refreshing Snowflake pipes and warehouse cleanup.

Bolt command settings

All command types available in Bolt schedules.