Parameters
Published pipes support Jinja2 syntax for parameter templating. Parameters help you write dynamic queries and provide more control over the results your queries return. In dashboards, you can prompt users for filter values and use those filters to query the data, returning only the relevant results. Example of a parameterized endpoint:
Data Types
Airfold allows the following data types for the value of the parameters. Supported data types:- String
- Int
- Float
- Boolean
- Date
- Datetime
{{ params }}
Example: SELECT * FROM t LIMIT {{ limit }}
The internal Jinja engine handles parameter substitution automatically. No need to escape parameters - WHERE name = {{ name }}
works correctly for string values.
Endpoint calls
All parameters are passed as query strings in the HTTP API.More Examples
UI
Create the Draft Pipe
Follow normal steps you would follow to create a draft pipe (refer Draft Pipes), make sure the query has the parameters enclosed in two curly braces like this:{{ params }}

Add parameters
Go to the three dots on top right corner and select “Add Parameter” and then select the Parameter Name, Data Type and and Default value.

Run the query
Once all the parameters are defined, you can just run the command and the query runs with the default values.
CLI
Edit YAML file
Once the query is ready simply add{{ params }}
where required and set the publish
property
top_referrers.yaml
Add Params
To define the parameters in the SQL query, we need to add theparams
property and define parameter name, type and default value.
top_referrers_with_parameters.yaml