CertSafari
    Databricks Certified Data Analyst Associate· Lessons

    Domain 6 · Lesson 26/39

    Named parameter markers in Databricks SQL

    Work with parameters in SQL queries and dashboards, including defining, configuring, and testing parameters.

    12 min read
    2.29% of exam
    4 sources
    Published 22 Oct 2026
    Docs as of 30 Sep 2026

    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.

    A hard-coded starting query. Replacing 5 with :fare_parameter turns it into a parameterized one.sql
    SELECT
      trip_distance,
      fare_amount
    FROM
      samples.nyctaxi.trips
    WHERE
      fare_amount < 5

    Defining 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?

    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 = ___

    Sources123

    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.

    Parameter types for named parameter markers in the SQL editor
    TypeWhat it acceptsWidget behaviour
    StringFree-form textQuotation marks and backslashes escaped; quotes added around the value
    IntegerWhole numbersNumeric entry
    DecimalNumbers with fractional valuesNumeric entry
    DateA dateCalendar picker, defaults to the current date
    TimestampA date and timeCalendar 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. 1.Click the gear icon next to the parameter widget that appears
    2. 2.Replace 5 in the WHERE clause with :fare_parameter
    3. 3.Set the parameter Type to Decimal
    4. 4.Enter a value in the widget and click Apply changes
    5. 5.Click Save

    Sources13

    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.

    SQL editor widget types and when each one fits
    Widget typeUser experienceUse it when
    Text inputAny free-form value, no suggestionsNo predefined options are needed
    DropdownMust choose from a static list you enterOnly a known set of values is valid
    ComboboxStatic list of suggestions, custom values allowedCommon options help, but other values are legitimate
    MultiselectSeveral values from a predefined list, passed as a collectionThe filter should match any of several values
    Dynamic dropdownChoices populated from a saved queryThe valid values change with the data
    Date and Timestamp rangeStart and end via .min and .maxThe 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.

    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. ? 

    Checkpoint 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?

    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.

    Mustache syntax and its named-marker equivalent
    Use caseMustache (legacy)Named parameter marker
    Filter by dateWHERE date_field < '{{date_param}}'WHERE date_field < :date_param
    Filter by numberWHERE price < {{max_price}}WHERE price < :max_price
    Compare stringsWHERE region = '{{region_param}}'WHERE region = :region_param
    Specify a tableSELECT * FROM {{table_name}}SELECT * FROM IDENTIFIER(:table) — use the full three-level namespace
    Create an intervalSELECT INTERVAL {{p}} MINUTESELECT CAST(format_string("INTERVAL '%s' MINUTE", :param) AS INTERVAL MINUTE)
    IDENTIFIER builds a fully qualified table name from three parameters at runtimesql
    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?

    Sources41

    Sources

    (4)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 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. 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. 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

    Continue to part 2 of 2

    Dashboard parameters, multi-select, date ranges and filter widgets

    Spotted a mistake, or was something unclear? Tell us.