What you will be able to do
- Write a typed :name parameter marker in place of a hard-coded value in a SQL query
- Define a parameter by typing its marker and configure its name, label, widget type and parameter type from the widget's gear icon
- Choose the parameter type and widget type that fit a given input, including dynamic dropdowns and date ranges
- Convert a legacy {{mustache}} query to named parameter syntax, including table names via IDENTIFIER
Key concept
Named parameter marker — A typed placeholder written as a colon followed by a name (:region) that stands in for a value in a SQL statement. The value is supplied when the query runs and is kept separate from the SQL text, so you can reuse the same query with many values.
1.The colon marks a parameter
A named parameter marker replaces a hard-coded value with a placeholder that someone fills in when the query runs. Without one, a query filtering fare_amount < 5 answers a single question. With fare_amount < :fare_parameter it answers that question for any threshold. Databricks lists three gains: the query is easier to reuse, it is protected against SQL injection, and it is easier to make interactive.
The syntax is a colon followed by an unqualified name, such as :region. The colon is required. It keeps parameter names in their own namespace, so :region cannot be mistaken for a column called region. You can use the same marker several times in one statement, and running a statement before any value has been bound to a marker raises an UNBOUND_SQL_PARAMETER error.
The same syntax works on every current Databricks surface: the SQL editor (new and legacy), notebooks, the AI/BI dashboard dataset editor and Genie Agents. If you need a viewer to pick a region later for a dashboard dataset, write WHERE region = :region. Prefixes such as @region or $region are not how Databricks marks a parameter. {{region}} is the older mustache syntax, which only the legacy SQL editor understands.
SELECT
trip_distance,
fare_amount
FROM
samples.nyctaxi.trips
WHERE
fare_amount < 5Defining a parameter means typing its marker into the query. Once :fare_parameter is in the WHERE clause, a widget for it appears in the UI, and removing the marker removes the widget.
Configuring happens in that widget. The gear icon opens a dialog with four fields: the parameter name as it appears in the query, a widget label that describes it to users, a widget type that controls how the value is entered, and a parameter type that fixes the data type. A well-configured widget lets users set values without ever editing the SQL.
Checkpoint 1 of 7· Check yourself
You are writing an AI/BI dashboard dataset query. Viewers should later pick a region from a filter widget. Which WHERE clause marks the parameter correctly?
Named parameter markers are a colon followed by a name, and they work in the AI/BI dashboard dataset editor. The colon is required because it keeps the parameter's name separate from column names. {{region}} is the older mustache syntax, which only the legacy SQL editor understands. Databricks does not use @ or $ to mark a parameter.
“Insert a parameter by typing a colon followed by a parameter name, such as :parameter_name.”Source: docs.databricks.com
Checkpoint 2 of 7· Exam question
An analyst is editing a dataset query for an AI/BI dashboard and wants to filter orders by a region that a viewer will choose later. Which syntax correctly defines a named parameter inside the SQL query for this purpose? SELECT * FROM sales.orders WHERE region = ___
Correct answer: A — :region
- A. The named colon marker is the syntax that AI/BI dashboard datasets recognize for substituting a runtime value into a query, and the query editor exposes an
Add parameteraction tied to this exact form. Selecting it lets the analyst configure a display name, type, and default value for the region filter. - B. Mustache-style double-brace substitution is a legacy Databricks SQL query syntax and is explicitly not supported for dashboard dataset parameters, so a query written this way will not surface a configurable parameter widget on the dashboard.
- C. An at-sign prefix is reserved for referencing an already-defined parameter's current value inside dashboard text widgets, not for declaring a new parameter inside a SQL WHERE clause.
- D. A bare dollar-sign prefix is not a recognized marker for AI/BI dashboard dataset parameters and would be treated as invalid or literal text rather than creating a substitutable value.
2.Setting the type and testing the query
As soon as you type a marker, a parameter widget appears under the query, and you set the value in the widget rather than in the SQL. To finish the fare example, click the gear icon next to the widget and set the Type to Decimal. Then enter a value, click Apply changes to run the query with it, and click Save. Changing the value and applying it again is how you test that the query behaves across the inputs you expect.
The type controls how Databricks reads the value at runtime, so choose it from the column you are comparing against.
| Type | What it accepts | Widget behaviour |
|---|---|---|
| String | Free-form text | Quotation marks and backslashes escaped; quotes added around the value |
| Integer | Whole numbers | Numeric entry |
| Decimal | Numbers with fractional values | Numeric entry |
| Date | A date | Calendar picker, defaults to the current date |
| Timestamp | A date and time | Calendar picker, defaults to the current date and time |
The widget dialog also holds the parameter name and a widget label. The name and the query are linked: if you rename the parameter in the dialog, you have to rename it in the query as well. To remove a parameter, delete the marker from the query and the widget is removed with it.
Checkpoint 3 of 7· Put it in order
You are turning the hard-coded fare query into a parameterized query in the SQL editor and testing it. Put these steps in order.
- 1.Click the gear icon next to the parameter widget that appears
- 2.Replace 5 in the WHERE clause with :fare_parameter
- 3.Set the parameter Type to Decimal
- 4.Enter a value in the widget and click Apply changes
- 5.Click Save
The widget only appears after you type the marker. You then open its settings from the gear icon and set the type to match the column. Next you enter a value and click Apply changes, which runs the query so you can test it. Saving comes last.
“Enter a value in the parameter widget and click Apply changes.”Source: docs.databricks.com
3.Widget types: from free text to dynamic dropdowns
The widget type decides how the user supplies a value, and it is separate from the parameter type. In the SQL editor, any parameter type can use any widget type. Choose the widget by how much freedom you want to give the user.
| Widget type | User experience | Use it when |
|---|---|---|
| Text input | Any free-form value, no suggestions | No predefined options are needed |
| Dropdown | Must choose from a static list you enter | Only a known set of values is valid |
| Combobox | Static list of suggestions, custom values allowed | Common options help, but other values are legitimate |
| Multiselect | Several values from a predefined list, passed as a collection | The filter should match any of several values |
| Dynamic dropdown | Choices populated from a saved query | The valid values change with the data |
| Date and Timestamp range | Start and end via .min and .max | The filter is a period rather than a single date |
A dynamic dropdown removes the upkeep of a static list. First create and save a query that returns the allowed values, such as the distinct c_mktsegment values from samples.tpch.customer. Then set the widget type to Dynamic dropdown, select the saved query in the Query field, choose a default value and apply the changes. When the underlying data changes, the options update with it. Two limits apply. The widget shows at most 1,024 values, and anything beyond the first 1,024 is not displayed. Dynamic dropdowns also work only in the SQL editor, not in notebooks.
A range widget on a Date or Timestamp parameter creates a start and an end, which you read in the query as :date_range.min and :date_range.max, usually inside a BETWEEN. Date widgets have a lightning-bolt icon for dynamic values such as last week or last month, which recalculate automatically. Those dynamic date values do not work with scheduled queries.
Checkpoint 4 of 7· Match them up
Match each SQL editor widget type to the situation it fits best.
Tap a term, then the definition that fits it.
Each widget type gives the user a different amount of freedom. Text input accepts anything. Dropdown restricts the user to a static list. Combobox suggests values from a list but also accepts custom ones. Multiselect passes several values as a collection. Dynamic dropdown reads its choices from a saved query, so the options keep up with the data.
“Combobox | Users can choose from a predefined list or type a custom value.”Source: docs.databricks.com
Checkpoint 5 of 7· Fill the gap
A Timestamp parameter in the SQL editor uses a range widget. Which suffix reads the end of the range?
SELECT * FROM samples.nyctaxi.trips
WHERE tpep_pickup_datetime
BETWEEN :date_range.min AND :date_range. ? With named parameter markers, a range widget creates a start and an end that you read as .min and .max. The .start and .end suffixes belong to the legacy mustache syntax and are not used with named parameters.
Source: docs.databricks.comCheckpoint 6 of 7· Exam question
A dashboard author configures a parameter's type as "Date Range" so viewers can pick a start and end date for a shipment report. After saving, the author needs to reference the range inside the dataset's WHERE clause. Which pair of generated parameter names should the author use?
Correct answer: A — :ship_date.min and :ship_date.max
- A. Choosing the Date Range type automatically creates two bound parameters that carry
.minand.maxsuffixes on the base keyword, and the WHERE clause is written asdate_col BETWEEN :ship_date.min AND :ship_date.maxto consume both bounds together. - B. Underscore-suffixed start and end names look plausible but are not the naming convention the range-type parameter generator produces; the query editor would not recognize these as bound to the range widget.
- C. Array-index bracket notation is not how Databricks exposes the two bounds of a date range parameter, and this syntax would fail to parse as a valid named parameter reference in the query.
- D. The words "from" and "to" read naturally for a range but are not the suffixes the platform actually generates; using them leaves the query referencing parameters that were never created.
Sources3
4.Converting legacy {{mustache}} queries
Queries written for the legacy SQL editor wrap parameters in double curly braces, and they do not run anywhere else. If you paste one into a notebook, a dashboard dataset or a Genie Agent, you have to convert it first. The new SQL editor also needs the conversion. Most conversions are mechanical: remove the braces and any quotes around them, then add a colon. Object names are different. A marker stands in for a value, so table and column names go through the IDENTIFIER clause.
| Use case | Mustache (legacy) | Named parameter marker |
|---|---|---|
| Filter by date | WHERE date_field < '{{date_param}}' | WHERE date_field < :date_param |
| Filter by number | WHERE price < {{max_price}} | WHERE price < :max_price |
| Compare strings | WHERE region = '{{region_param}}' | WHERE region = :region_param |
| Specify a table | SELECT * FROM {{table_name}} | SELECT * FROM IDENTIFIER(:table) — use the full three-level namespace |
| Create an interval | SELECT INTERVAL {{p}} MINUTE | SELECT CAST(format_string("INTERVAL '%s' MINUTE", :param) AS INTERVAL MINUTE) |
SELECT *
FROM IDENTIFIER(:catalog || '.' || :schema || '.' || :table)Two mustache habits cause trouble after conversion. First, legacy date ranges use .start and .end suffixes, but named markers use .min and .max. Second, legacy multi-value dropdowns are written as IN ( {{ status_param }} ) with a Quotation setting. Named markers have no equivalent. The multi-select pattern for named markers is array_contains (in the SQL editor, applied to a comma-separated string split into an array).
Checkpoint 7 of 7· Check yourself
A legacy SQL editor query reads SELECT * FROM {{table_name}} WHERE region = '{{region_param}}'. It now has to run in a notebook. Which version will run there?
A marker stands in for a value, so a table name must go through IDENTIFIER(:table), with the full three-level namespace. For the value filter, you remove the braces and the quotes around them and add a colon, because Databricks quotes String values itself. Mustache syntax runs only in the legacy SQL editor, so a notebook needs the converted version.
“SELECT * FROM {{table_name}} | SELECT * FROM IDENTIFIER(:table) — use the full three-level namespace”Source: docs.databricks.com
Sources
(4)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Insert a parameter by typing a colon followed by a parameter name, such as :parameter_name.”
↩︎ The colon marks a parameter“This improves query reuse, prevents SQL injection, and makes it easier to build flexible, interactive queries.”
↩︎ The colon marks a parameter“Enter a value in the parameter widget and click Apply changes.”
↩︎ Setting the type and testing the query“Use the IDENTIFIER function to pass a column name as a parameter.”
↩︎ Converting legacy {{mustache}} queries“Date and Timestamp parameters support a range widget. Use .min and .max to access the start and end of the range.”
↩︎ Exam trap 2“Backslash, single, and double quotation marks are escaped automatically. Databricks adds quotation marks around the value.”
↩︎ Prediction“SELECT * FROM {{table_name}} | SELECT * FROM IDENTIFIER(:table) — use the full three-level namespace”
↩︎ Checkpoint - 2.
“The mandatory preceding : (colon) differentiates the namespace of named parameter markers from that of column names and SQL parameters.”
↩︎ The colon marks a parameter“If no value has been bound to the parameter marker an UNBOUND_SQL_PARAMETER error is raised.”
↩︎ The colon marks a parameter“Using parameter markers protects your code from SQL injection attacks since it clearly separates provided values from the structure of the SQL statements.”
↩︎ Key concept - 3.
“Add a named parameter marker to your query. A widget appears in the UI.”
↩︎ The colon marks a parameter“You can configure each widget's type, title, and default value.”
↩︎ The colon marks a parameter“If you change the parameter name, in the widget dialog, you must also change it in the query.”
↩︎ Setting the type and testing the query“Remove: Delete the parameter marker from the query. The widget is removed automatically.”
↩︎ Setting the type and testing the query“In the SQL editor, any parameter type (String, Integer, Decimal, Date, Timestamp) can use any widget type.”
↩︎ Widget types: from free text to dynamic dropdowns“A dynamic dropdown displays a maximum of 1,024 values.”
↩︎ Widget types: from free text to dynamic dropdowns“Dynamic date values are not compatible with scheduled queries.”
↩︎ Widget types: from free text to dynamic dropdowns“Dynamic dropdown widgets are available in the SQL editor only, not in notebooks.”
↩︎ Exam trap 1“Combobox | Users can choose from a predefined list or type a custom value.”
↩︎ Checkpoint - 4.
“you must convert it to named parameter markers before it will run.”
↩︎ Converting legacy {{mustache}} queries“When you select a Range option, Databricks creates two parameters using .start and .end suffixes”
↩︎ Converting legacy {{mustache}} queries