Use Runtime Variables¶
Runtime variables let a quality check, or the SQL of a computed asset, reference a value that is supplied when the scan runs, instead of hard-coding it. A common use is a filter that targets a reporting date or a business unit that changes from one scan to the next.
Related pages: Scan Settings · Scan API · Scan FAQ
How Variables Work¶
Write a variable in a check as a name inside double curly braces, for example {{ checked_date }}. When a scan runs, Qualytics replaces each variable with its value and then evaluates the check.
Variables are supported in:
- The check's Filter Clause.
- Rule properties that hold an expression, a filter, or a pattern, such as the expression of a Satisfies Expression check or the reference filter of an Aggregation Comparison check.
- Lists of text values, such as the list of an Expected Values check on a text field. Lists of numbers or of true/false values do not accept variables.
- The SQL of a Computed Table, Computed File, or Computed Join. See Variables in Computed Asset SQL.
In the check editor, fields that accept variables highlight them as you type.
A check filter that uses a variable must still be a valid Spark SQL WHERE expression once the value is in place. For example:
Scans and reconciliation
In checks, variables are filled in during Scan operations and when the Data Reconciliation recipe materializes a Data Diff check's golden set, which fills the check's filter and reference filter the same way its scan did. Profile operations and other Materialize operations do not use them.
Saving a check does not test the filter with your values
When you save a check, variables in its filter and reference filter are treated as null during validation, so you can save the check before any value exists. This also means a container default or scan value that makes the filter invalid is not caught on save. It only fails when the scan runs. Variables in other rule properties, such as the expression of a Satisfies Expression check, are filled from the container's default values when one exists (the built-in _qualytics_ variables always have a value) and are otherwise replaced with nothing, so the check can be saved only if the expression is still valid. For example, o_orderdate <> {{ checked_date }} cannot be saved unless the container defines a default for checked_date. To test a check with real values first, call POST /api/quality-checks/validate (or POST /api/quality-checks/{id}/validate for an existing check) with the check in quality_check and the values in check_variables.
Where Values Come From¶
A variable can get its value from two places. When the same variable is defined in both, the scan value wins:
| Priority | Source | Use it for |
|---|---|---|
| 1 (lowest) | The container's Additional Metadata | Default values that apply to every scan of that container. |
| 2 (highest) | The scan's Scan Variables, or check_variables in the API |
Values for one scan or one schedule. These override the container defaults. |
Qualytics also provides built-in variables. A value you define with the same name as a built-in variable replaces it, so do not start your own variable names with _qualytics_.
Set Default Values on a Container¶
Step 1: Open the container's settings: click the vertical ellipsis next to the container in the datastore's list and select Settings. For a Computed Table, Computed File, or Computed Join, you can also use its add or edit form. See General Settings.
Step 2: In Additional Metadata, click the plus icon and add one row per variable. The key is the variable name (without the curly braces) and the value is what replaces it.
Step 3: Save. Every scan that includes this container now uses these values unless the scan supplies its own.
Scanning several containers at once
For checks, a scan combines the Additional Metadata of every container it includes into a single set of values. If two containers in the same scan define the same key with different values, only one of the values is used in their checks. Give each container's variables distinct names, or set the value in Scan Variables for that scan. The SQL of a computed asset is different: it always uses its own container's values.
Supply Values for a Scan¶
Step 1: Open the Scan operation modal and continue to Scan Settings.
Step 2: Toggle Advanced Options on.
Step 3: In Scan Variables, add one row per variable you want to set or override for this scan.
Step 4: Run the scan, or save it as a schedule. Scheduled scans keep their Scan Variables and use them on every run.
Supply Values Through the API¶
Pass the values in the check_variables field when calling /api/operations/run:
{
"type": "scan",
"datastore_id": 42,
"container_names": ["my_container"],
"incremental": true,
"max_records_analyzed_per_partition": null,
"check_variables": {
"checked_date": "TIMESTAMP '2026-05-15'"
},
"high_count_rollup_threshold": 10
}
"max_records_analyzed_per_partition": null removes the record limit within the chosen read strategy. This example uses Incremental, so later runs still skip records before the saved baseline. Do not send 0: it analyzes no records, so the scan finds nothing, and a Full scan with Auto Resolve on can close anomalies that are still open.
Scan schedules accept the same check_variables field. For the full payload reference, see API.
Variables in Computed Asset SQL¶
The SQL of a computed asset can use variables too, so a scan can change which rows the source returns before any data is read. Variables work in:
- A Computed Table's query.
- A Computed File's query. A Computed File still defined by separate clauses takes them in its select, filter, and group by clauses until its query replaces them.
- A Computed Join's query and source filters in SQL mode, or its select, filter, and group by clauses in pairwise mode.
For example, a Computed Table that reads one business unit's orders for a reporting window:
SELECT order_id, amount, posting_date
FROM orders
WHERE business_unit = '{{ business_unit }}'
AND posting_date BETWEEN DATE '{{ period_start }}' AND DATE '{{ period_end }}'
A variable name starts with a letter or an underscore and contains only letters, digits, and underscores. Text in double curly braces that is not such a name, for example {{ cost center }}, is sent to the source as written.
In the add and edit forms, the SQL editors highlight each variable. Typing {{ offers the Additional Metadata keys that hold a default value, and a variable without a default is underlined in red.
Every variable needs a default. Add each variable the SQL uses to the asset's Additional Metadata, using its name as the key. While a variable has no default, the add and edit forms show A variable needs a value below Additional Metadata, naming each missing variable, and the asset cannot be validated or saved. The same applies to a change in the asset's Settings: a default that the SQL still uses cannot be removed.
If an operation still finds a variable without a value, it fails and names the variable, instead of sending the SQL with an empty value.
Where values come from. A scan fills in the SQL with its Scan Variables (or check_variables in the API), and uses the asset's default for any variable the scan does not set. Each asset only uses its own defaults, even when several assets in one scan use the same variable name. A scan value applies to every asset in that scan that uses the variable.
Other operations use the defaults. Profile, Materialize, preview, and volume and freshness measurements always use the defaults in Additional Metadata. Profile statistics, inferred checks, and the volume history therefore describe the default rows, not the rows a particular scan read.
Rerun and restart a scan use the Scan Variables the original scan was given, together with the asset's current defaults.
A value is inserted into the SQL exactly as you type it, so write the quotes and casts the source expects, as in the example above. For a Computed Table, the value must be valid in your source's own SQL dialect.
Scans that switch between separate sets of rows
Auto Resolve Anomalies treats each Full scan as covering the whole container. If scans of the same asset read separate sets of rows, for example EMEA on one run and AMER on the next, the AMER scan resolves the anomalies the EMEA scan found, and the next EMEA scan raises them again. Turn Auto Resolve Anomalies off in the Scan Settings of those scans and schedules. Scans that move a date window forward, so each run reads the latest period, are not affected.
Write Values with Explicit Types¶
A value is inserted into the check exactly as you type it, so it must be valid SQL in that position. Include quotes and casts yourself:
| Variable type | Example value | Resulting filter |
|---|---|---|
| Timestamp | TIMESTAMP '2026-05-15' |
transaction_date = TIMESTAMP '2026-05-15' |
| Date | DATE '2026-05-15' |
posting_date >= DATE '2026-05-15' |
| String | 'EMEA' |
business_unit = 'EMEA' |
| Number | 100 |
amount > 100 |
You can also keep the quotes in the check itself, for example business_unit = '{{ unit }}', and supply the value without quotes (EMEA).
Built-in Variables¶
These variables are always available and do not need a value:
| Variable | Replaced with |
|---|---|
{{ _qualytics_self }} |
The data being scanned, usable as a table name inside a subquery. |
{{ _qualytics_container_id }} |
The identifier of the container the check runs against. |
{{ _qualytics_operation_id }} |
The identifier of the scan operation that is running. |
For an example that uses {{ _qualytics_self }}, see Satisfies Expression: How It Works.