Skip to main content
Query templates use placeholders to mark variable parts of a query. When a user runs a template, they provide values for each placeholder, and the system substitutes them into the query before execution.

Placeholder syntax

Placeholders use double curly braces with a name:
Placeholder names should be:
  • Descriptive and self-documenting
  • Lowercase with underscores for word separation
  • Unique within the template
Examples:
  • {{start_date}} - a date parameter
  • {{min_revenue_threshold}} - a numeric threshold
  • {{target_region}} - a string filter value

Placeholder types

Each placeholder has a type that determines what values it accepts and how the value is substituted into the query.

Literal value placeholders

Replace constants like strings, numbers, booleans, or dates. Supported types: Example:

Column placeholders

Replace column names in SELECT, GROUP BY, or ORDER BY clauses. Use these when users need to choose which fields appear in results. Example:
Column placeholders should specify which columns are valid options in the placeholder metadata. This prevents users from selecting columns that don’t exist or aren’t appropriate for the query context.

Filter placeholders

Replace entire WHERE conditions. Use these when the filtering logic itself varies, not just the filter values. Example:
A user might provide region = 'EMEA' AND total > 1000 for the custom_filter placeholder.
Filter placeholders give users significant flexibility. Use them only when necessary, and document expected filter formats clearly.

Output field placeholders

Replace parts of the SELECT list. Use these when the shape of the output depends on user choice. Example:
A user might provide email, phone, account_type for the output_fields placeholder.

Placeholder metadata

Each placeholder includes metadata that describes how users should interact with it.

Required vs. optional placeholders

  • Required placeholders must have values before the query can execute
  • Optional placeholders use their default value if the user doesn’t provide one
Example with optional placeholder:
If the user doesn’t provide a status value, the query uses 'active'.

Complete example

Here’s a complete template with multiple placeholder types:
Placeholder definitions:

Materialized view templates

Templates can create materialized views, allowing users to generate scheduled data products with customized parameters.
For materialized view options, see Materialized View Syntax.

Using Query Templates

Step-by-step guide to creating and using templates

Query Templates

Understand when and why to use templates

NQL Data Types

Complete reference for NQL data types

NQL Syntax

Core NQL syntax reference