SQL task for jobs

Use the SQL task type to configure a SQL query, legacy dashboard, alert, or SQL file.

The SQL task requires Databricks SQL and a serverless or pro SQL warehouse.

Configure a SQL task

Before you begin, you must have your SQL asset in a location accessible by the user configuring the job.

Note

The jobs UI displays options dynamically based on other configured settings.

To begin the flow to configure a SQL task:

  1. Navigate to the Tasks tab in the Jobs UI.
  2. In the Type drop-down menu, select SQL.

Configure the SQL task type

In the SQL task drop-down menu, select a SQL task type using one of the following options.

Query

Select a SQL query to run against the specified SQL warehouse.

Legacy dashboard

Select a Legacy dashboard to update using the specified SQL warehouse.

(Optional) Add Subscribers to send a report with the updated dashboard.

Alert

Select a SQL alert to evaluate using the specified SQL warehouse.

(Optional) Add Subscribers to notify with the results of the alert.

File

Use File to run a .sql file using the specified SQL warehouse.

The file can contain multiple SQL statements separated by semicolons (;).

You must configure a Source for the SQL file using one of the following options.

Workspace

Use Workspace to configure a SQL file stored as a workspace file.

  1. Click the Path field. The Select SQL file dialog appears.
  2. Browse to the SQL file, click to highlight the file, and click Confirm.

Note

You can use this option to configure a task for a SQL file stored in a Databricks Git folder. Databricks recommends using the Git provider option with a remote Git repository to version assets scheduled with jobs.

Git provider

Use Git provider to configure a SQL file stored in a remote Git repository.

The options displayed by the UI depend on whether or not you have already configured a Git provider elsewhere. Only one remote Git repository can be used for all tasks in a job. See Use Git with jobs.

The Path field appears after you have configured a git reference.

Enter the relative path for your notebook, such as etl/bronze/ingest.sql.

Important

When you enter the relative path, don't begin with / or ./. For example, if the absolute path for the notebook you want to access is /etl/bronze/ingest.sql, enter etl/bronze/ingest.sql in the Path field.

Finalize job configuration

  1. (Optional) Configure Parameters as key-value pairs referenced in the configured SQL asset. Alerts do not support parameters. See Configure task parameters.
  2. Click Save task.